2022-05-05 13:15:32 +02:00
|
|
|
// remove (name) from pathname as it's not considered for routing
|
2022-05-25 11:46:26 +02:00
|
|
|
export function normalizeAppPath(pathname: string) {
|
2022-05-05 13:15:32 +02:00
|
|
|
let normalized = ''
|
|
|
|
const segments = pathname.split('/')
|
|
|
|
|
|
|
|
segments.forEach((segment, index) => {
|
|
|
|
if (!segment) return
|
|
|
|
if (segment.startsWith('(') && segment.endsWith(')')) {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
if (segment === 'page' && index === segments.length - 1) {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
normalized += `/${segment}`
|
|
|
|
})
|
|
|
|
return normalized
|
|
|
|
}
|