aboutsummaryrefslogtreecommitdiff
path: root/client/js/router.js
diff options
context:
space:
mode:
authorrr-2016-07-07 21:18:35 +0200
committerrr-2016-07-08 00:54:24 +0200
commit5ac5eb550380e9c9a5c4fdbbbf08fadbe01ff4a9 (patch)
tree7aedc28b8fef9e62d8624fdd85a095ae90efa8e6 /client/js/router.js
parentcd1f4709f0c636c6cbcf62c90c7df0eb593c6c3c (diff)
client/general: refactor URL parameter handling
Diffstat (limited to 'client/js/router.js')
-rw-r--r--client/js/router.js11
1 files changed, 6 insertions, 5 deletions
diff --git a/client/js/router.js b/client/js/router.js
index 426d6d4..490b804 100644
--- a/client/js/router.js
+++ b/client/js/router.js
@@ -39,7 +39,7 @@ class Context {
this.title = document.title;
this.state = state || {};
this.state.path = path;
- this.params = {};
+ this.parameters = {};
}
pushState() {
@@ -61,14 +61,14 @@ class Route {
middleware(fn) {
return (ctx, next) => {
- if (this.match(ctx.path, ctx.params)) {
+ if (this.match(ctx.path, ctx.parameters)) {
return fn(ctx, next);
}
next();
};
}
- match(path, params) {
+ match(path, parameters) {
const keys = this.keys;
const qsIndex = path.indexOf('?');
const pathname = ~qsIndex ? path.slice(0, qsIndex) : path;
@@ -81,8 +81,9 @@ class Route {
for (let i = 1, len = m.length; i < len; ++i) {
const key = keys[i - 1];
const val = _decodeURLEncodedURIComponent(m[i]);
- if (val !== undefined || !(hasOwnProperty.call(params, key.name))) {
- params[key.name] = val;
+ if (val !== undefined ||
+ !(hasOwnProperty.call(parameters, key.name))) {
+ parameters[key.name] = val;
}
}

© 2015 - 2026 Jakob L. Kreuze