@@ -13,12 +13,13 @@ import { stripLiteral } from 'strip-literal'
13
13
import type { Plugin } from '../plugin'
14
14
import type { ViteDevServer } from '../server'
15
15
import {
16
+ encodeURIPath ,
16
17
generateCodeFrame ,
17
18
getHash ,
18
19
isDataUrl ,
19
20
isExternalUrl ,
20
21
normalizePath ,
21
- partialEncodeURI ,
22
+ partialEncodeURIPath ,
22
23
processSrcSet ,
23
24
removeLeadingSlash ,
24
25
urlCanParse ,
@@ -439,7 +440,7 @@ export function buildHtmlPlugin(config: ResolvedConfig): Plugin {
439
440
overwriteAttrValue (
440
441
s ,
441
442
sourceCodeLocation ! ,
442
- partialEncodeURI ( toOutputPublicFilePath ( url ) ) ,
443
+ partialEncodeURIPath ( toOutputPublicFilePath ( url ) ) ,
443
444
)
444
445
}
445
446
@@ -498,7 +499,7 @@ export function buildHtmlPlugin(config: ResolvedConfig): Plugin {
498
499
if ( ! isExcludedUrl ( decodedUrl ) ) {
499
500
const result = await processAssetUrl ( url )
500
501
return result !== decodedUrl
501
- ? encodeURI ( result )
502
+ ? encodeURIPath ( result )
502
503
: url
503
504
}
504
505
return url
@@ -519,7 +520,7 @@ export function buildHtmlPlugin(config: ResolvedConfig): Plugin {
519
520
overwriteAttrValue (
520
521
s ,
521
522
getAttrSourceCodeLocation ( node , attrKey ) ,
522
- partialEncodeURI ( toOutputPublicFilePath ( url ) ) ,
523
+ partialEncodeURIPath ( toOutputPublicFilePath ( url ) ) ,
523
524
)
524
525
} else if ( ! isExcludedUrl ( url ) ) {
525
526
if (
@@ -563,7 +564,7 @@ export function buildHtmlPlugin(config: ResolvedConfig): Plugin {
563
564
overwriteAttrValue (
564
565
s ,
565
566
getAttrSourceCodeLocation ( node , attrKey ) ,
566
- partialEncodeURI ( processedUrl ) ,
567
+ partialEncodeURIPath ( processedUrl ) ,
567
568
)
568
569
}
569
570
} ) ( ) ,
@@ -636,12 +637,16 @@ export function buildHtmlPlugin(config: ResolvedConfig): Plugin {
636
637
// emit <script>import("./aaa")</script> asset
637
638
for ( const { start, end, url } of scriptUrls ) {
638
639
if ( checkPublicFile ( url , config ) ) {
639
- s . update ( start , end , partialEncodeURI ( toOutputPublicFilePath ( url ) ) )
640
+ s . update (
641
+ start ,
642
+ end ,
643
+ partialEncodeURIPath ( toOutputPublicFilePath ( url ) ) ,
644
+ )
640
645
} else if ( ! isExcludedUrl ( url ) ) {
641
646
s . update (
642
647
start ,
643
648
end ,
644
- partialEncodeURI ( await urlToBuiltUrl ( url , id , config , this ) ) ,
649
+ partialEncodeURIPath ( await urlToBuiltUrl ( url , id , config , this ) ) ,
645
650
)
646
651
}
647
652
}
@@ -904,15 +909,15 @@ export function buildHtmlPlugin(config: ResolvedConfig): Plugin {
904
909
if ( chunk ) {
905
910
chunk . viteMetadata ! . importedAssets . add ( cleanUrl ( file ) )
906
911
}
907
- return encodeURI ( toOutputAssetFilePath ( file ) ) + postfix
912
+ return encodeURIPath ( toOutputAssetFilePath ( file ) ) + postfix
908
913
} )
909
914
910
915
result = result . replace ( publicAssetUrlRE , ( _ , fileHash ) => {
911
916
const publicAssetPath = toOutputPublicAssetFilePath (
912
917
getPublicAssetFilename ( fileHash , config ) ! ,
913
918
)
914
919
915
- return encodeURI (
920
+ return encodeURIPath (
916
921
urlCanParse ( publicAssetPath )
917
922
? publicAssetPath
918
923
: normalizePath ( publicAssetPath ) ,
0 commit comments