Skip to content

Commit 51ed059

Browse files
authored
perf: improve multilineCommentsRE regex (fix #10689) (#10751)
1 parent 4a392f0 commit 51ed059

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

packages/vite/src/node/utils.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -912,7 +912,8 @@ export function toUpperCaseDriveLetter(pathName: string): string {
912912
return pathName.replace(/^\w:/, (letter) => letter.toUpperCase())
913913
}
914914

915-
export const multilineCommentsRE = /\/\*(.|[\r\n])*?\*\//gm
915+
// Taken from https://stackoverflow.com/a/36328890
916+
export const multilineCommentsRE = /\/\*[^*]*\*+(?:[^/*][^*]*\*+)*\//gm
916917
export const singlelineCommentsRE = /\/\/.*/g
917918
export const requestQuerySplitRE = /\?(?!.*[\/|\}])/
918919

0 commit comments

Comments
 (0)