Fix route regexps aren't global
+ Version 0.4.21
This commit is contained in:
parent
d0c77e645f
commit
0591daf93f
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "wms-core",
|
||||
"version": "0.4.20",
|
||||
"version": "0.4.21",
|
||||
"description": "Node web framework",
|
||||
"repository": "git@gitlab.com:ArisuOngaku/wms-core.git",
|
||||
"author": "Alice Gaudon <alice@gaudon.pro>",
|
||||
|
@ -12,16 +12,16 @@ export default abstract class Controller {
|
||||
if (path === undefined) throw new Error(`Unknown route for name ${route}.`);
|
||||
|
||||
if (typeof params === 'string' || typeof params === 'number') {
|
||||
path = path.replace(/:[a-zA-Z_-]+\??/, '' + params);
|
||||
path = path.replace(/:[a-zA-Z_-]+\??/g, '' + params);
|
||||
} else if (Array.isArray(params)) {
|
||||
let i = 0;
|
||||
for (const match of path.matchAll(/:[a-zA-Z_-]+\??/)) {
|
||||
for (const match of path.matchAll(/:[a-zA-Z_-]+\??/g)) {
|
||||
if (match.length > 0) {
|
||||
path = path.replace(match[0], typeof params[i] !== 'undefined' ? params[i] : '');
|
||||
}
|
||||
i++;
|
||||
}
|
||||
path = path.replace(/\/+/, '/');
|
||||
path = path.replace(/\/+/g, '/');
|
||||
} else {
|
||||
for (const key in params) {
|
||||
if (params.hasOwnProperty(key)) {
|
||||
|
Loading…
Reference in New Issue
Block a user