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.
- package/dist/handler/index.js +21 -24
- package/dist/handler/utils.js +29 -29
- package/dist/index.js +28 -31
- package/dist/layer/index.js +23 -26
- package/dist/layer/module.js +74 -82
- package/dist/layer/type.js +9 -9
- package/dist/layer/utils.js +17 -15
- package/dist/path/index.js +22 -25
- package/dist/path/matcher.js +74 -74
- package/dist/path/type.js +9 -9
- package/dist/route/index.js +23 -26
- package/dist/route/module.js +135 -125
- package/dist/route/type.js +9 -9
- package/dist/route/utils.js +17 -15
- package/dist/router/index.js +22 -25
- package/dist/router/module.js +294 -285
- package/dist/router/type.js +9 -3
- package/dist/type.js +9 -9
- package/dist/utils/index.js +24 -27
- package/dist/utils/is-instance.js +16 -16
- package/dist/utils/path.js +16 -14
- package/dist/utils/promise.js +19 -19
- package/dist/utils/request.js +33 -32
- package/package.json +11 -6
- package/dist/handler/index.js.map +0 -1
- package/dist/handler/utils.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/layer/index.js.map +0 -1
- package/dist/layer/module.js.map +0 -1
- package/dist/layer/type.js.map +0 -1
- package/dist/layer/utils.js.map +0 -1
- package/dist/path/index.js.map +0 -1
- package/dist/path/matcher.js.map +0 -1
- package/dist/path/type.js.map +0 -1
- package/dist/route/index.js.map +0 -1
- package/dist/route/module.js.map +0 -1
- package/dist/route/type.js.map +0 -1
- package/dist/route/utils.js.map +0 -1
- package/dist/router/index.js.map +0 -1
- package/dist/router/module.js.map +0 -1
- package/dist/router/type.js.map +0 -1
- package/dist/type.js.map +0 -1
- package/dist/utils/index.js.map +0 -1
- package/dist/utils/is-instance.js.map +0 -1
- package/dist/utils/path.js.map +0 -1
- package/dist/utils/promise.js.map +0 -1
- package/dist/utils/request.js.map +0 -1
package/dist/handler/index.js
CHANGED
|
@@ -1,24 +1,21 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
})
|
|
19
|
-
|
|
20
|
-
|
|
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
|
+
}
|
package/dist/handler/utils.js
CHANGED
|
@@ -1,29 +1,29 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
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
|
-
|
|
2
|
-
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
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
|
+
}
|
package/dist/layer/index.js
CHANGED
|
@@ -1,26 +1,23 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
Object.
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
|
|
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
|
+
}
|
package/dist/layer/module.js
CHANGED
|
@@ -1,82 +1,74 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
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
|
+
}
|
package/dist/layer/type.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
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
|
+
});
|
package/dist/layer/utils.js
CHANGED
|
@@ -1,15 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
|
|
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
|
+
}
|
package/dist/path/index.js
CHANGED
|
@@ -1,25 +1,22 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
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
|
+
}
|
package/dist/path/matcher.js
CHANGED
|
@@ -1,74 +1,74 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
const fastSlash = this.path === '/' && this.regexpOptions.end === false;
|
|
32
|
-
if (fastSlash) {
|
|
33
|
-
return
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
|
|
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
|
+
}
|