optional splat routes (#13547)
Co-authored-by: SteelRazor47 <36779933+SteelRazor47@users.noreply.github.com>
This commit is contained in:
@@ -4,7 +4,11 @@ export function getRoute(file: string): string {
|
||||
const importPath = normalizePath(file)
|
||||
return importPath
|
||||
.replace(/.*\/admin\/(routes)/, "")
|
||||
.replace(/\[([^\]]+)\]/g, ":$1")
|
||||
.replace("[[*]]", "*?") // optional splat
|
||||
.replace("[*]", "*") // splat
|
||||
.replace(/\(([^\[\]\)]+)\)/g, "$1?") // optional static, (foo)
|
||||
.replace(/\[\[([^\]]+)\]\]/g, ":$1?") // optional dynamic, [[foo]]
|
||||
.replace(/\[([^\]]+)\]/g, ":$1") // dynamic, [foo]
|
||||
.replace(
|
||||
new RegExp(
|
||||
`/page\\.(${VALID_FILE_EXTENSIONS.map((ext) => ext.slice(1)).join(
|
||||
|
||||
Reference in New Issue
Block a user