routup 0.10.0 → 0.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. package/dist/handler/index.js +21 -24
  2. package/dist/handler/utils.js +29 -29
  3. package/dist/index.js +28 -31
  4. package/dist/layer/index.js +23 -26
  5. package/dist/layer/module.js +74 -82
  6. package/dist/layer/type.js +9 -9
  7. package/dist/layer/utils.js +17 -15
  8. package/dist/path/index.js +22 -25
  9. package/dist/path/matcher.js +74 -74
  10. package/dist/path/type.js +9 -9
  11. package/dist/route/index.js +23 -26
  12. package/dist/route/module.js +135 -125
  13. package/dist/route/type.js +9 -9
  14. package/dist/route/utils.js +17 -15
  15. package/dist/router/index.js +22 -25
  16. package/dist/router/module.js +294 -285
  17. package/dist/router/type.js +9 -3
  18. package/dist/type.js +9 -9
  19. package/dist/utils/index.js +24 -27
  20. package/dist/utils/is-instance.js +16 -16
  21. package/dist/utils/path.js +16 -14
  22. package/dist/utils/promise.js +19 -19
  23. package/dist/utils/request.js +33 -32
  24. package/package.json +11 -6
  25. package/dist/handler/index.js.map +0 -1
  26. package/dist/handler/utils.js.map +0 -1
  27. package/dist/index.js.map +0 -1
  28. package/dist/layer/index.js.map +0 -1
  29. package/dist/layer/module.js.map +0 -1
  30. package/dist/layer/type.js.map +0 -1
  31. package/dist/layer/utils.js.map +0 -1
  32. package/dist/path/index.js.map +0 -1
  33. package/dist/path/matcher.js.map +0 -1
  34. package/dist/path/type.js.map +0 -1
  35. package/dist/route/index.js.map +0 -1
  36. package/dist/route/module.js.map +0 -1
  37. package/dist/route/type.js.map +0 -1
  38. package/dist/route/utils.js.map +0 -1
  39. package/dist/router/index.js.map +0 -1
  40. package/dist/router/module.js.map +0 -1
  41. package/dist/router/type.js.map +0 -1
  42. package/dist/type.js.map +0 -1
  43. package/dist/utils/index.js.map +0 -1
  44. package/dist/utils/is-instance.js.map +0 -1
  45. package/dist/utils/path.js.map +0 -1
  46. package/dist/utils/promise.js.map +0 -1
  47. package/dist/utils/request.js.map +0 -1
@@ -1,24 +1,21 @@
1
- "use strict";
2
- /*
3
- * Copyright (c) 2022.
4
- * Author Peter Placzek (tada5hi)
5
- * For the full copyright and license information,
6
- * view the LICENSE file that was distributed with this source code.
7
- */
8
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
9
- if (k2 === undefined) k2 = k;
10
- var desc = Object.getOwnPropertyDescriptor(m, k);
11
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
12
- desc = { enumerable: true, get: function() { return m[k]; } };
13
- }
14
- Object.defineProperty(o, k2, desc);
15
- }) : (function(o, m, k, k2) {
16
- if (k2 === undefined) k2 = k;
17
- o[k2] = m[k];
18
- }));
19
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
20
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
21
- };
22
- Object.defineProperty(exports, "__esModule", { value: true });
23
- __exportStar(require("./utils"), exports);
24
- //# sourceMappingURL=index.js.map
1
+ /*
2
+ * Copyright (c) 2022.
3
+ * Author Peter Placzek (tada5hi)
4
+ * For the full copyright and license information,
5
+ * view the LICENSE file that was distributed with this source code.
6
+ */ "use strict";
7
+ Object.defineProperty(exports, "__esModule", {
8
+ value: true
9
+ });
10
+ _exportStar(require("./utils"), exports);
11
+ function _exportStar(from, to) {
12
+ Object.keys(from).forEach(function(k) {
13
+ if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) Object.defineProperty(to, k, {
14
+ enumerable: true,
15
+ get: function() {
16
+ return from[k];
17
+ }
18
+ });
19
+ });
20
+ return from;
21
+ }
@@ -1,29 +1,29 @@
1
- "use strict";
2
- /*
3
- * Copyright (c) 2022-2022.
4
- * Author Peter Placzek (tada5hi)
5
- * For the full copyright and license information,
6
- * view the LICENSE file that was distributed with this source code.
7
- */
8
- Object.defineProperty(exports, "__esModule", { value: true });
9
- exports.processHandlerExecutionOutput = void 0;
10
- const core_1 = require("@routup/core");
11
- const utils_1 = require("../utils");
12
- function processHandlerExecutionOutput(res, next, output) {
13
- if ((0, utils_1.isPromise)(output)) {
14
- output
15
- .then((r) => {
16
- if (typeof r !== 'undefined') {
17
- (0, core_1.send)(res, r);
18
- }
19
- return r;
20
- })
21
- .catch(next);
22
- return;
23
- }
24
- if (typeof output !== 'undefined') {
25
- (0, core_1.send)(res, output);
26
- }
27
- }
28
- exports.processHandlerExecutionOutput = processHandlerExecutionOutput;
29
- //# sourceMappingURL=utils.js.map
1
+ /*
2
+ * Copyright (c) 2022-2022.
3
+ * Author Peter Placzek (tada5hi)
4
+ * For the full copyright and license information,
5
+ * view the LICENSE file that was distributed with this source code.
6
+ */ "use strict";
7
+ Object.defineProperty(exports, "__esModule", {
8
+ value: true
9
+ });
10
+ Object.defineProperty(exports, "processHandlerExecutionOutput", {
11
+ enumerable: true,
12
+ get: ()=>processHandlerExecutionOutput
13
+ });
14
+ const _core = require("@routup/core");
15
+ const _utils = require("../utils");
16
+ function processHandlerExecutionOutput(res, next, output) {
17
+ if ((0, _utils.isPromise)(output)) {
18
+ output.then((r)=>{
19
+ if (typeof r !== 'undefined') {
20
+ (0, _core.send)(res, r);
21
+ }
22
+ return r;
23
+ }).catch(next);
24
+ return;
25
+ }
26
+ if (typeof output !== 'undefined') {
27
+ (0, _core.send)(res, output);
28
+ }
29
+ }
package/dist/index.js CHANGED
@@ -1,31 +1,28 @@
1
- "use strict";
2
- /*
3
- * Copyright (c) 2022.
4
- * Author Peter Placzek (tada5hi)
5
- * For the full copyright and license information,
6
- * view the LICENSE file that was distributed with this source code.
7
- */
8
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
9
- if (k2 === undefined) k2 = k;
10
- var desc = Object.getOwnPropertyDescriptor(m, k);
11
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
12
- desc = { enumerable: true, get: function() { return m[k]; } };
13
- }
14
- Object.defineProperty(o, k2, desc);
15
- }) : (function(o, m, k, k2) {
16
- if (k2 === undefined) k2 = k;
17
- o[k2] = m[k];
18
- }));
19
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
20
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
21
- };
22
- Object.defineProperty(exports, "__esModule", { value: true });
23
- __exportStar(require("./handler"), exports);
24
- __exportStar(require("./layer"), exports);
25
- __exportStar(require("./path"), exports);
26
- __exportStar(require("./route"), exports);
27
- __exportStar(require("./router"), exports);
28
- __exportStar(require("./type"), exports);
29
- __exportStar(require("./utils"), exports);
30
- __exportStar(require("@routup/core"), exports);
31
- //# sourceMappingURL=index.js.map
1
+ /*
2
+ * Copyright (c) 2022.
3
+ * Author Peter Placzek (tada5hi)
4
+ * For the full copyright and license information,
5
+ * view the LICENSE file that was distributed with this source code.
6
+ */ "use strict";
7
+ Object.defineProperty(exports, "__esModule", {
8
+ value: true
9
+ });
10
+ _exportStar(require("./handler"), exports);
11
+ _exportStar(require("./layer"), exports);
12
+ _exportStar(require("./path"), exports);
13
+ _exportStar(require("./route"), exports);
14
+ _exportStar(require("./router"), exports);
15
+ _exportStar(require("./type"), exports);
16
+ _exportStar(require("./utils"), exports);
17
+ _exportStar(require("@routup/core"), exports);
18
+ function _exportStar(from, to) {
19
+ Object.keys(from).forEach(function(k) {
20
+ if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) Object.defineProperty(to, k, {
21
+ enumerable: true,
22
+ get: function() {
23
+ return from[k];
24
+ }
25
+ });
26
+ });
27
+ return from;
28
+ }
@@ -1,26 +1,23 @@
1
- "use strict";
2
- /*
3
- * Copyright (c) 2022.
4
- * Author Peter Placzek (tada5hi)
5
- * For the full copyright and license information,
6
- * view the LICENSE file that was distributed with this source code.
7
- */
8
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
9
- if (k2 === undefined) k2 = k;
10
- var desc = Object.getOwnPropertyDescriptor(m, k);
11
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
12
- desc = { enumerable: true, get: function() { return m[k]; } };
13
- }
14
- Object.defineProperty(o, k2, desc);
15
- }) : (function(o, m, k, k2) {
16
- if (k2 === undefined) k2 = k;
17
- o[k2] = m[k];
18
- }));
19
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
20
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
21
- };
22
- Object.defineProperty(exports, "__esModule", { value: true });
23
- __exportStar(require("./module"), exports);
24
- __exportStar(require("./type"), exports);
25
- __exportStar(require("./utils"), exports);
26
- //# sourceMappingURL=index.js.map
1
+ /*
2
+ * Copyright (c) 2022.
3
+ * Author Peter Placzek (tada5hi)
4
+ * For the full copyright and license information,
5
+ * view the LICENSE file that was distributed with this source code.
6
+ */ "use strict";
7
+ Object.defineProperty(exports, "__esModule", {
8
+ value: true
9
+ });
10
+ _exportStar(require("./module"), exports);
11
+ _exportStar(require("./type"), exports);
12
+ _exportStar(require("./utils"), exports);
13
+ function _exportStar(from, to) {
14
+ Object.keys(from).forEach(function(k) {
15
+ if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) Object.defineProperty(to, k, {
16
+ enumerable: true,
17
+ get: function() {
18
+ return from[k];
19
+ }
20
+ });
21
+ });
22
+ return from;
23
+ }
@@ -1,82 +1,74 @@
1
- "use strict";
2
- /*
3
- * Copyright (c) 2022.
4
- * Author Peter Placzek (tada5hi)
5
- * For the full copyright and license information,
6
- * view the LICENSE file that was distributed with this source code.
7
- */
8
- Object.defineProperty(exports, "__esModule", { value: true });
9
- exports.Layer = void 0;
10
- const http_1 = require("@ebec/http");
11
- const core_1 = require("@routup/core");
12
- const handler_1 = require("../handler");
13
- const path_1 = require("../path");
14
- class Layer {
15
- // --------------------------------------------------
16
- constructor(options, fn) {
17
- this['@instanceof'] = Symbol.for('Layer');
18
- this.pathMatcher = new path_1.PathMatcher(options.path, options.pathMatcher);
19
- this.fn = fn;
20
- }
21
- // --------------------------------------------------
22
- isError() {
23
- return this.fn.length === 4;
24
- }
25
- dispatch(req, res, meta, next, err) {
26
- (0, core_1.setRequestParams)(req, meta.params || {});
27
- (0, core_1.setRequestMountPath)(req, meta.mountPath || '/');
28
- if (typeof err !== 'undefined') {
29
- if (this.fn.length === 4) {
30
- try {
31
- this.fn(err, req, res, next);
32
- }
33
- catch (e) {
34
- /* istanbul ignore next */
35
- /* istanbul ignore next */
36
- if (e instanceof Error) {
37
- next(e);
38
- }
39
- else {
40
- next(new http_1.BadRequestError({
41
- message: 'The request could not be processed by the error handler.',
42
- }));
43
- }
44
- }
45
- return;
46
- }
47
- /* istanbul ignore next */
48
- next(err);
49
- /* istanbul ignore next */
50
- return;
51
- }
52
- /* istanbul ignore next */
53
- if (this.fn.length > 3) {
54
- next();
55
- return;
56
- }
57
- try {
58
- const output = this.fn(req, res, next);
59
- (0, handler_1.processHandlerExecutionOutput)(res, next, output);
60
- }
61
- catch (e) {
62
- /* istanbul ignore next */
63
- if (e instanceof Error) {
64
- next(e);
65
- }
66
- else {
67
- next(new http_1.BadRequestError({
68
- message: 'The request could not be processed by the handler.',
69
- }));
70
- }
71
- }
72
- }
73
- // --------------------------------------------------
74
- matchPath(path) {
75
- return this.pathMatcher.test(path);
76
- }
77
- exec(path) {
78
- return this.pathMatcher.exec(path);
79
- }
80
- }
81
- exports.Layer = Layer;
82
- //# sourceMappingURL=module.js.map
1
+ /*
2
+ * Copyright (c) 2022.
3
+ * Author Peter Placzek (tada5hi)
4
+ * For the full copyright and license information,
5
+ * view the LICENSE file that was distributed with this source code.
6
+ */ "use strict";
7
+ Object.defineProperty(exports, "__esModule", {
8
+ value: true
9
+ });
10
+ Object.defineProperty(exports, "Layer", {
11
+ enumerable: true,
12
+ get: ()=>Layer
13
+ });
14
+ const _http = require("@ebec/http");
15
+ const _core = require("@routup/core");
16
+ const _handler = require("../handler");
17
+ const _path = require("../path");
18
+ class Layer {
19
+ // --------------------------------------------------
20
+ isError() {
21
+ return this.fn.length === 4;
22
+ }
23
+ dispatch(req, res, meta, next, err) {
24
+ (0, _core.setRequestParams)(req, meta.params || {});
25
+ (0, _core.setRequestMountPath)(req, meta.mountPath || '/');
26
+ if (typeof err !== 'undefined') {
27
+ if (this.fn.length === 4) {
28
+ try {
29
+ this.fn(err, req, res, next);
30
+ } catch (e) {
31
+ /* istanbul ignore next */ /* istanbul ignore next */ if (e instanceof Error) {
32
+ next(e);
33
+ } else {
34
+ next(new _http.BadRequestError({
35
+ message: 'The request could not be processed by the error handler.'
36
+ }));
37
+ }
38
+ }
39
+ return;
40
+ }
41
+ /* istanbul ignore next */ next(err);
42
+ /* istanbul ignore next */ return;
43
+ }
44
+ /* istanbul ignore next */ if (this.fn.length > 3) {
45
+ next();
46
+ return;
47
+ }
48
+ try {
49
+ const output = this.fn(req, res, next);
50
+ (0, _handler.processHandlerExecutionOutput)(res, next, output);
51
+ } catch (e) {
52
+ /* istanbul ignore next */ if (e instanceof Error) {
53
+ next(e);
54
+ } else {
55
+ next(new _http.BadRequestError({
56
+ message: 'The request could not be processed by the handler.'
57
+ }));
58
+ }
59
+ }
60
+ }
61
+ // --------------------------------------------------
62
+ matchPath(path) {
63
+ return this.pathMatcher.test(path);
64
+ }
65
+ exec(path) {
66
+ return this.pathMatcher.exec(path);
67
+ }
68
+ // --------------------------------------------------
69
+ constructor(options, fn){
70
+ this['@instanceof'] = Symbol.for('Layer');
71
+ this.pathMatcher = new _path.PathMatcher(options.path, options.pathMatcher);
72
+ this.fn = fn;
73
+ }
74
+ }
@@ -1,9 +1,9 @@
1
- "use strict";
2
- /*
3
- * Copyright (c) 2022.
4
- * Author Peter Placzek (tada5hi)
5
- * For the full copyright and license information,
6
- * view the LICENSE file that was distributed with this source code.
7
- */
8
- Object.defineProperty(exports, "__esModule", { value: true });
9
- //# sourceMappingURL=type.js.map
1
+ /*
2
+ * Copyright (c) 2022.
3
+ * Author Peter Placzek (tada5hi)
4
+ * For the full copyright and license information,
5
+ * view the LICENSE file that was distributed with this source code.
6
+ */ "use strict";
7
+ Object.defineProperty(exports, "__esModule", {
8
+ value: true
9
+ });
@@ -1,15 +1,17 @@
1
- "use strict";
2
- /*
3
- * Copyright (c) 2022.
4
- * Author Peter Placzek (tada5hi)
5
- * For the full copyright and license information,
6
- * view the LICENSE file that was distributed with this source code.
7
- */
8
- Object.defineProperty(exports, "__esModule", { value: true });
9
- exports.isLayerInstance = void 0;
10
- const utils_1 = require("../utils");
11
- function isLayerInstance(input) {
12
- return (0, utils_1.isInstance)(input, 'Layer');
13
- }
14
- exports.isLayerInstance = isLayerInstance;
15
- //# sourceMappingURL=utils.js.map
1
+ /*
2
+ * Copyright (c) 2022.
3
+ * Author Peter Placzek (tada5hi)
4
+ * For the full copyright and license information,
5
+ * view the LICENSE file that was distributed with this source code.
6
+ */ "use strict";
7
+ Object.defineProperty(exports, "__esModule", {
8
+ value: true
9
+ });
10
+ Object.defineProperty(exports, "isLayerInstance", {
11
+ enumerable: true,
12
+ get: ()=>isLayerInstance
13
+ });
14
+ const _utils = require("../utils");
15
+ function isLayerInstance(input) {
16
+ return (0, _utils.isInstance)(input, 'Layer');
17
+ }
@@ -1,25 +1,22 @@
1
- "use strict";
2
- /*
3
- * Copyright (c) 2022.
4
- * Author Peter Placzek (tada5hi)
5
- * For the full copyright and license information,
6
- * view the LICENSE file that was distributed with this source code.
7
- */
8
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
9
- if (k2 === undefined) k2 = k;
10
- var desc = Object.getOwnPropertyDescriptor(m, k);
11
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
12
- desc = { enumerable: true, get: function() { return m[k]; } };
13
- }
14
- Object.defineProperty(o, k2, desc);
15
- }) : (function(o, m, k, k2) {
16
- if (k2 === undefined) k2 = k;
17
- o[k2] = m[k];
18
- }));
19
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
20
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
21
- };
22
- Object.defineProperty(exports, "__esModule", { value: true });
23
- __exportStar(require("./matcher"), exports);
24
- __exportStar(require("./type"), exports);
25
- //# sourceMappingURL=index.js.map
1
+ /*
2
+ * Copyright (c) 2022.
3
+ * Author Peter Placzek (tada5hi)
4
+ * For the full copyright and license information,
5
+ * view the LICENSE file that was distributed with this source code.
6
+ */ "use strict";
7
+ Object.defineProperty(exports, "__esModule", {
8
+ value: true
9
+ });
10
+ _exportStar(require("./matcher"), exports);
11
+ _exportStar(require("./type"), exports);
12
+ function _exportStar(from, to) {
13
+ Object.keys(from).forEach(function(k) {
14
+ if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) Object.defineProperty(to, k, {
15
+ enumerable: true,
16
+ get: function() {
17
+ return from[k];
18
+ }
19
+ });
20
+ });
21
+ return from;
22
+ }
@@ -1,74 +1,74 @@
1
- "use strict";
2
- /*
3
- * Copyright (c) 2022.
4
- * Author Peter Placzek (tada5hi)
5
- * For the full copyright and license information,
6
- * view the LICENSE file that was distributed with this source code.
7
- */
8
- Object.defineProperty(exports, "__esModule", { value: true });
9
- exports.PathMatcher = void 0;
10
- const path_to_regexp_1 = require("path-to-regexp");
11
- function decodeParam(val) {
12
- /* istanbul ignore next */
13
- if (typeof val !== 'string' || val.length === 0) {
14
- return val;
15
- }
16
- return decodeURIComponent(val);
17
- }
18
- class PathMatcher {
19
- constructor(path, options) {
20
- this.regexpKeys = [];
21
- this.path = path;
22
- this.regexpOptions = options || {};
23
- if (path instanceof RegExp) {
24
- this.regexp = path;
25
- }
26
- else {
27
- this.regexp = (0, path_to_regexp_1.pathToRegexp)(path, this.regexpKeys, options);
28
- }
29
- }
30
- test(path) {
31
- const fastSlash = this.path === '/' && this.regexpOptions.end === false;
32
- if (fastSlash) {
33
- return true;
34
- }
35
- return this.regexp.test(path);
36
- }
37
- exec(path) {
38
- let match = null;
39
- const fastSlash = this.path === '/' && this.regexpOptions.end === false;
40
- if (fastSlash) {
41
- return {
42
- path: '/',
43
- params: {},
44
- };
45
- }
46
- match = this.regexp.exec(path);
47
- if (!match) {
48
- return undefined;
49
- }
50
- if (this.path instanceof RegExp) {
51
- return {
52
- path,
53
- params: {
54
- 0: decodeParam(match[0]),
55
- },
56
- };
57
- }
58
- const output = {};
59
- for (let i = 1; i < match.length; i++) {
60
- const key = this.regexpKeys[i - 1];
61
- const prop = key.name;
62
- const val = decodeParam(match[i]);
63
- if (typeof val !== 'undefined') {
64
- output[prop] = val;
65
- }
66
- }
67
- return {
68
- path: match[0],
69
- params: output,
70
- };
71
- }
72
- }
73
- exports.PathMatcher = PathMatcher;
74
- //# sourceMappingURL=matcher.js.map
1
+ /*
2
+ * Copyright (c) 2022.
3
+ * Author Peter Placzek (tada5hi)
4
+ * For the full copyright and license information,
5
+ * view the LICENSE file that was distributed with this source code.
6
+ */ "use strict";
7
+ Object.defineProperty(exports, "__esModule", {
8
+ value: true
9
+ });
10
+ Object.defineProperty(exports, "PathMatcher", {
11
+ enumerable: true,
12
+ get: ()=>PathMatcher
13
+ });
14
+ const _pathToRegexp = require("path-to-regexp");
15
+ function decodeParam(val) {
16
+ /* istanbul ignore next */ if (typeof val !== 'string' || val.length === 0) {
17
+ return val;
18
+ }
19
+ return decodeURIComponent(val);
20
+ }
21
+ class PathMatcher {
22
+ test(path) {
23
+ const fastSlash = this.path === '/' && this.regexpOptions.end === false;
24
+ if (fastSlash) {
25
+ return true;
26
+ }
27
+ return this.regexp.test(path);
28
+ }
29
+ exec(path) {
30
+ let match = null;
31
+ const fastSlash = this.path === '/' && this.regexpOptions.end === false;
32
+ if (fastSlash) {
33
+ return {
34
+ path: '/',
35
+ params: {}
36
+ };
37
+ }
38
+ match = this.regexp.exec(path);
39
+ if (!match) {
40
+ return undefined;
41
+ }
42
+ if (this.path instanceof RegExp) {
43
+ return {
44
+ path,
45
+ params: {
46
+ 0: decodeParam(match[0])
47
+ }
48
+ };
49
+ }
50
+ const output = {};
51
+ for(let i = 1; i < match.length; i++){
52
+ const key = this.regexpKeys[i - 1];
53
+ const prop = key.name;
54
+ const val = decodeParam(match[i]);
55
+ if (typeof val !== 'undefined') {
56
+ output[prop] = val;
57
+ }
58
+ }
59
+ return {
60
+ path: match[0],
61
+ params: output
62
+ };
63
+ }
64
+ constructor(path, options){
65
+ this.regexpKeys = [];
66
+ this.path = path;
67
+ this.regexpOptions = options || {};
68
+ if (path instanceof RegExp) {
69
+ this.regexp = path;
70
+ } else {
71
+ this.regexp = (0, _pathToRegexp.pathToRegexp)(path, this.regexpKeys, options);
72
+ }
73
+ }
74
+ }