Unverified Commit 382dbb82 authored by Tim Neutkens's avatar Tim Neutkens Committed by GitHub

Use charCodeAt for normalizePathTrailingSlash (#91380)

## What?

Using `charCodeAt` is faster than startWith for this case.
parent ff7d0398
...@@ -6,7 +6,8 @@ import { parsePath } from '../shared/lib/router/utils/parse-path' ...@@ -6,7 +6,8 @@ import { parsePath } from '../shared/lib/router/utils/parse-path'
* in `next.config.js`. * in `next.config.js`.
*/ */
export const normalizePathTrailingSlash = (path: string) => { export const normalizePathTrailingSlash = (path: string) => {
if (!path.startsWith('/') || process.env.__NEXT_MANUAL_TRAILING_SLASH) { // 47 is the char code for '/'
if (path.charCodeAt(0) !== 47 || process.env.__NEXT_MANUAL_TRAILING_SLASH) {
return path return path
} }
......
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