Skip to content

Commit 8dc1b73

Browse files
perf: remove unnecessary regex s modifier (#15766)
1 parent 18b9b31 commit 8dc1b73

File tree

4 files changed

+4
-4
lines changed

4 files changed

+4
-4
lines changed

packages/vite/src/client/client.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -435,7 +435,7 @@ export function injectQuery(url: string, queryToInject: string): string {
435435
}
436436

437437
// can't use pathname from URL since it may be relative like ../
438-
const pathname = url.replace(/[?#].*$/s, '')
438+
const pathname = url.replace(/[?#].*$/, '')
439439
const { search, hash } = new URL(url, 'http://vitejs.dev')
440440

441441
return `${pathname}?${queryToInject}${search ? `&` + search.slice(1) : ''}${

packages/vite/src/node/plugins/importAnalysis.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1030,7 +1030,7 @@ function __vite__injectQuery(url: string, queryToInject: string): string {
10301030
}
10311031

10321032
// can't use pathname from URL since it may be relative like ../
1033-
const pathname = url.replace(/[?#].*$/s, '')
1033+
const pathname = url.replace(/[?#].*$/, '')
10341034
const { search, hash } = new URL(url, 'http://vitejs.dev')
10351035

10361036
return `${pathname}?${queryToInject}${search ? `&` + search.slice(1) : ''}${

packages/vite/src/node/ssr/runtime/utils.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ export function slash(p: string): string {
2727
return p.replace(windowsSlashRE, '/')
2828
}
2929

30-
const postfixRE = /[?#].*$/s
30+
const postfixRE = /[?#].*$/
3131
export function cleanUrl(url: string): string {
3232
return url.replace(postfixRE, '')
3333
}

packages/vite/src/node/utils.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@ export function isSameFileUri(file1: string, file2: string): boolean {
295295

296296
export const queryRE = /\?.*$/s
297297

298-
const postfixRE = /[?#].*$/s
298+
const postfixRE = /[?#].*$/
299299
export function cleanUrl(url: string): string {
300300
return url.replace(postfixRE, '')
301301
}

0 commit comments

Comments
 (0)