diff --git a/.eslintrc.json b/.eslintrc.json index 224a065e585b8a4..3f4f64868a1e323 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -203,7 +203,14 @@ "no-octal-escape": "warn", "no-redeclare": ["warn", { "builtinGlobals": false }], "no-regex-spaces": "warn", - "no-restricted-syntax": ["warn", "WithStatement"], + "no-restricted-syntax": [ + "warn", + "WithStatement", + { + "message": "substr() is deprecated, use slice() or substring() instead", + "selector": "MemberExpression > Identifier[name='substr']" + } + ], "no-script-url": "warn", "no-self-assign": "warn", "no-self-compare": "warn", diff --git a/packages/next/server/router-utils.ts b/packages/next/server/router-utils.ts index 630521434fdbf8a..c25ea5eeb572fb3 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