Skip to content

Commit

Permalink
perf: remove unnecessary regex s modifier (#15766)
Browse files Browse the repository at this point in the history
  • Loading branch information
MajedMuhammad authored Feb 21, 2024
1 parent 18b9b31 commit 8dc1b73
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion packages/vite/src/client/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,7 @@ export function injectQuery(url: string, queryToInject: string): string {
}

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

return `${pathname}?${queryToInject}${search ? `&` + search.slice(1) : ''}${
Expand Down
2 changes: 1 addition & 1 deletion packages/vite/src/node/plugins/importAnalysis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1030,7 +1030,7 @@ function __vite__injectQuery(url: string, queryToInject: string): string {
}

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

return `${pathname}?${queryToInject}${search ? `&` + search.slice(1) : ''}${
Expand Down
2 changes: 1 addition & 1 deletion packages/vite/src/node/ssr/runtime/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export function slash(p: string): string {
return p.replace(windowsSlashRE, '/')
}

const postfixRE = /[?#].*$/s
const postfixRE = /[?#].*$/
export function cleanUrl(url: string): string {
return url.replace(postfixRE, '')
}
Expand Down
2 changes: 1 addition & 1 deletion packages/vite/src/node/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ export function isSameFileUri(file1: string, file2: string): boolean {

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

const postfixRE = /[?#].*$/s
const postfixRE = /[?#].*$/
export function cleanUrl(url: string): string {
return url.replace(postfixRE, '')
}
Expand Down

0 comments on commit 8dc1b73

Please sign in to comment.