diff --git a/packages/next/server/router-utils.ts b/packages/next/server/router-utils.ts index 630521434fdb..c25ea5eeb572 100644 --- a/packages/next/server/router-utils.ts +++ b/packages/next/server/router-utils.ts @@ -3,7 +3,7 @@ export function replaceBasePath(pathname: string, basePath: string): string { // and doesn't contain extra chars e.g. basePath /docs // should replace for /docs, /docs/, /docs/a but not /docsss if (hasBasePath(pathname, basePath)) { - pathname = pathname.substr(basePath.length) + pathname = pathname.slice(basePath.length) if (!pathname.startsWith('/')) pathname = `/${pathname}` } return pathname