@@ -13,12 +13,13 @@ import { stripLiteral } from 'strip-literal'
1313import type { Plugin } from '../plugin'
1414import type { ViteDevServer } from '../server'
1515import {
16+ encodeURIPath ,
1617 generateCodeFrame ,
1718 getHash ,
1819 isDataUrl ,
1920 isExternalUrl ,
2021 normalizePath ,
21- partialEncodeURI ,
22+ partialEncodeURIPath ,
2223 processSrcSet ,
2324 removeLeadingSlash ,
2425 urlCanParse ,
@@ -439,7 +440,7 @@ export function buildHtmlPlugin(config: ResolvedConfig): Plugin {
439440 overwriteAttrValue (
440441 s ,
441442 sourceCodeLocation ! ,
442- partialEncodeURI ( toOutputPublicFilePath ( url ) ) ,
443+ partialEncodeURIPath ( toOutputPublicFilePath ( url ) ) ,
443444 )
444445 }
445446
@@ -498,7 +499,7 @@ export function buildHtmlPlugin(config: ResolvedConfig): Plugin {
498499 if ( ! isExcludedUrl ( decodedUrl ) ) {
499500 const result = await processAssetUrl ( url )
500501 return result !== decodedUrl
501- ? encodeURI ( result )
502+ ? encodeURIPath ( result )
502503 : url
503504 }
504505 return url
@@ -519,7 +520,7 @@ export function buildHtmlPlugin(config: ResolvedConfig): Plugin {
519520 overwriteAttrValue (
520521 s ,
521522 getAttrSourceCodeLocation ( node , attrKey ) ,
522- partialEncodeURI ( toOutputPublicFilePath ( url ) ) ,
523+ partialEncodeURIPath ( toOutputPublicFilePath ( url ) ) ,
523524 )
524525 } else if ( ! isExcludedUrl ( url ) ) {
525526 if (
@@ -563,7 +564,7 @@ export function buildHtmlPlugin(config: ResolvedConfig): Plugin {
563564 overwriteAttrValue (
564565 s ,
565566 getAttrSourceCodeLocation ( node , attrKey ) ,
566- partialEncodeURI ( processedUrl ) ,
567+ partialEncodeURIPath ( processedUrl ) ,
567568 )
568569 }
569570 } ) ( ) ,
@@ -636,12 +637,16 @@ export function buildHtmlPlugin(config: ResolvedConfig): Plugin {
636637 // emit <script>import("./aaa")</script> asset
637638 for ( const { start, end, url } of scriptUrls ) {
638639 if ( checkPublicFile ( url , config ) ) {
639- s . update ( start , end , partialEncodeURI ( toOutputPublicFilePath ( url ) ) )
640+ s . update (
641+ start ,
642+ end ,
643+ partialEncodeURIPath ( toOutputPublicFilePath ( url ) ) ,
644+ )
640645 } else if ( ! isExcludedUrl ( url ) ) {
641646 s . update (
642647 start ,
643648 end ,
644- partialEncodeURI ( await urlToBuiltUrl ( url , id , config , this ) ) ,
649+ partialEncodeURIPath ( await urlToBuiltUrl ( url , id , config , this ) ) ,
645650 )
646651 }
647652 }
@@ -904,15 +909,15 @@ export function buildHtmlPlugin(config: ResolvedConfig): Plugin {
904909 if ( chunk ) {
905910 chunk . viteMetadata ! . importedAssets . add ( cleanUrl ( file ) )
906911 }
907- return encodeURI ( toOutputAssetFilePath ( file ) ) + postfix
912+ return encodeURIPath ( toOutputAssetFilePath ( file ) ) + postfix
908913 } )
909914
910915 result = result . replace ( publicAssetUrlRE , ( _ , fileHash ) => {
911916 const publicAssetPath = toOutputPublicAssetFilePath (
912917 getPublicAssetFilename ( fileHash , config ) ! ,
913918 )
914919
915- return encodeURI (
920+ return encodeURIPath (
916921 urlCanParse ( publicAssetPath )
917922 ? publicAssetPath
918923 : normalizePath ( publicAssetPath ) ,
0 commit comments