Unverified Commit a9437d1d authored by Niklas Mischkulnig's avatar Niklas Mischkulnig Committed by GitHub

fix: use removePathPrefix instead of regex (#100063)

This unescaped regex looked dangerous (I didn't run into any particular
bugs).
Just replace it with some equivalent logic without needing a regex
parent 5ce27fa7
...@@ -14,6 +14,7 @@ import { ...@@ -14,6 +14,7 @@ import {
prepareDestination, prepareDestination,
} from '../shared/lib/router/utils/prepare-destination' } from '../shared/lib/router/utils/prepare-destination'
import { removeTrailingSlash } from '../shared/lib/router/utils/remove-trailing-slash' import { removeTrailingSlash } from '../shared/lib/router/utils/remove-trailing-slash'
import { removePathPrefix } from '../shared/lib/router/utils/remove-path-prefix'
import { normalizeRscURL } from '../shared/lib/router/utils/app-paths' import { normalizeRscURL } from '../shared/lib/router/utils/app-paths'
import { import {
NEXT_CACHE_REVALIDATE_TAG_TOKEN_HEADER, NEXT_CACHE_REVALIDATE_TAG_TOKEN_HEADER,
...@@ -318,7 +319,7 @@ export function getServerUtils({ ...@@ -318,7 +319,7 @@ export function getServerUtils({
if (!fsPathname) return false if (!fsPathname) return false
if (basePath) { if (basePath) {
fsPathname = fsPathname.replace(new RegExp(`^${basePath}`), '') || '/' fsPathname = removePathPrefix(fsPathname, basePath)
} }
if (i18n) { if (i18n) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment