Support route parameter regex in controller route function
This commit is contained in:
parent
fa42b8991b
commit
fa3e5bdb19
@ -15,7 +15,7 @@ export default abstract class Controller {
|
|||||||
path = path.replace(/:[a-zA-Z_-]+\??/g, '' + params);
|
path = path.replace(/:[a-zA-Z_-]+\??/g, '' + params);
|
||||||
} else if (Array.isArray(params)) {
|
} else if (Array.isArray(params)) {
|
||||||
let i = 0;
|
let i = 0;
|
||||||
for (const match of path.matchAll(/:[a-zA-Z_-]+\??/g)) {
|
for (const match of path.matchAll(/:[a-zA-Z_-]+(\(.*\))?\??/g)) {
|
||||||
if (match.length > 0) {
|
if (match.length > 0) {
|
||||||
path = path.replace(match[0], typeof params[i] !== 'undefined' ? params[i] : '');
|
path = path.replace(match[0], typeof params[i] !== 'undefined' ? params[i] : '');
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user