fix: normalise index before slugifying

This commit is contained in:
Daniel Roe 2023-10-16 13:39:35 +01:00 committed by GitHub
parent 75990c5dbc
commit 7db327cf9b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -6,7 +6,7 @@ export function getNameFromPath (path: string, relativeTo?: string) {
const relativePath = relativeTo const relativePath = relativeTo
? normalize(path).replace(withTrailingSlash(normalize(relativeTo)), '') ? normalize(path).replace(withTrailingSlash(normalize(relativeTo)), '')
: basename(path) : basename(path)
return kebabCase(relativePath.replace(/[\\/]+/g, '-').replace(/\/index\.\w+$/, '').replace(extname(relativePath), '')).replace(/["']/g, '') return kebabCase(relativePath.replace(/\/index\.\w+$/, '').replace(/[\\/]+/g, '-').replace(extname(relativePath), '')).replace(/["']/g, '')
} }
export function hasSuffix (path: string, suffix: string) { export function hasSuffix (path: string, suffix: string) {