Skip to content

Commit

Permalink
perf: simplify isHtmlProxy regex (#15590)
Browse files Browse the repository at this point in the history
  • Loading branch information
patak-dev authored Jan 16, 2024
1 parent af2aa09 commit 644d120
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions packages/vite/src/node/plugins/html.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ interface ScriptAssetsUrl {

const htmlProxyRE =
/\?html-proxy=?(?:&inline-css)?(?:&style-attr)?&index=(\d+)\.(js|css)$/
const isHtmlProxyRE = /\?html-proxy\b/

const inlineCSSRE = /__VITE_INLINE_CSS__([a-z\d]{8}_\d+)__/g
// Do not allow preceding '.', but do allow preceding '...' for spread operations
const inlineImportRE =
Expand All @@ -63,7 +65,7 @@ const importMapAppendRE = new RegExp(
'i',
)

export const isHTMLProxy = (id: string): boolean => htmlProxyRE.test(id)
export const isHTMLProxy = (id: string): boolean => isHtmlProxyRE.test(id)

export const isHTMLRequest = (request: string): boolean =>
htmlLangRE.test(request)
Expand All @@ -88,7 +90,7 @@ export function htmlInlineProxyPlugin(config: ResolvedConfig): Plugin {
name: 'vite:html-inline-proxy',

resolveId(id) {
if (htmlProxyRE.test(id)) {
if (isHTMLProxy(id)) {
return id
}
},
Expand Down

0 comments on commit 644d120

Please sign in to comment.