silverwolf-x/project / packages /next /src /shared /lib /page-path /normalize-data-path.ts
silverwolf-x's picture
download
raw
428 Bytes
import { pathHasPrefix } from '../router/utils/path-has-prefix'
/**
* strip _next/data/<build-id>/ prefix and .json suffix
*/
export function normalizeDataPath(pathname: string) {
if (!pathHasPrefix(pathname || '/', '/_next/data')) {
return pathname
}
pathname = pathname
.replace(/\/_next\/data\/[^/]{1,}/, '')
.replace(/\.json$/, '')
if (pathname === '/index') {
return '/'
}
return pathname
}

Xet Storage Details

Size:
428 Bytes
·
Xet hash:
63566af294a031a10a2e210bcdb976ca9bd0757abbcc55b9a2bf880d38d646d8

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.