jj.js 0.8.7 → 0.8.8
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/lib/url.js +9 -8
- package/package.json +1 -1
package/lib/url.js
CHANGED
|
@@ -55,14 +55,15 @@ class Url extends Context
|
|
|
55
55
|
url = routes[url].url;
|
|
56
56
|
|
|
57
57
|
if(~url.indexOf(':')) {
|
|
58
|
-
url = url.replace(/\:([
|
|
59
|
-
key = key.split(
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
58
|
+
url = url.replace(/\:([^/]+\(.*\)|[^/]+)/g, (match, key) => {
|
|
59
|
+
key = key.split(/[(.]/);
|
|
60
|
+
const k = key[0];
|
|
61
|
+
if(k in query) {
|
|
62
|
+
const value = query[k];
|
|
63
|
+
delete query[k];
|
|
64
|
+
return querystring.escape(value) + (!key[1] || ~key[1].indexOf(')') ? '' : '.' + key[1]);
|
|
65
|
+
} else if(this.ctx.params && k in this.ctx.params) {
|
|
66
|
+
return querystring.escape(this.ctx.params[k]);
|
|
66
67
|
}
|
|
67
68
|
return match;
|
|
68
69
|
});
|