Skip to content

Commit 68d500e

Browse files
authored
perf: improve cleanUrl util (#12573)
1 parent e9b92f5 commit 68d500e

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

packages/vite/src/node/utils.ts

+4-3
Original file line numberDiff line numberDiff line change
@@ -256,10 +256,11 @@ export function ensureVolumeInPath(file: string): string {
256256
}
257257

258258
export const queryRE = /\?.*$/s
259-
export const hashRE = /#.*$/s
260259

261-
export const cleanUrl = (url: string): string =>
262-
url.replace(hashRE, '').replace(queryRE, '')
260+
const postfixRE = /[?#].*$/s
261+
export function cleanUrl(url: string): string {
262+
return url.replace(postfixRE, '')
263+
}
263264

264265
export const externalRE = /^(https?:)?\/\//
265266
export const isExternalUrl = (url: string): boolean => externalRE.test(url)

0 commit comments

Comments
 (0)