@@ -140,6 +140,10 @@ function withCommentsStripped<T>(
140140 return { result, restore } ;
141141}
142142
143+ function resolveRelativeUrlPath ( fromDir : string , basePath : string ) : string {
144+ return resolve ( fromDir , decodeWellFormedEscapes ( basePath . replaceAll ( "\\" , "/" ) ) ) ;
145+ }
146+
143147function rebaseCssUrls ( css : string , cssFileDir : string , projectDir : string ) : string {
144148 const resolvedRoot = resolve ( projectDir ) ;
145149 const resolvedDir = resolve ( cssFileDir ) ;
@@ -149,7 +153,7 @@ function rebaseCssUrls(css: string, cssFileDir: string, projectDir: string): str
149153 if ( ! decoded || ! isRelativeUrl ( decoded ) ) return full ;
150154 const { basePath, suffix } = splitUrlSuffix ( decoded ) ;
151155 if ( ! basePath ) return full ;
152- const absolutePath = resolve ( resolvedDir , decodeWellFormedEscapes ( basePath ) ) ;
156+ const absolutePath = resolveRelativeUrlPath ( resolvedDir , basePath ) ;
153157 const rebased = encodeUrlPath ( relative ( resolvedRoot , absolutePath ) . split ( sep ) . join ( "/" ) ) ;
154158 if ( rebased === basePath ) return full ;
155159 const escapedSuffix = suffix . replace (
@@ -163,7 +167,7 @@ function rebaseCssUrls(css: string, cssFileDir: string, projectDir: string): str
163167function rebaseRelativePath ( urlValue : string , fromDir : string , toDir : string ) : string {
164168 const { basePath, suffix } = splitUrlSuffix ( urlValue . trim ( ) ) ;
165169 if ( ! basePath ) return urlValue ;
166- const absolutePath = resolve ( fromDir , decodeWellFormedEscapes ( basePath ) ) ;
170+ const absolutePath = resolveRelativeUrlPath ( fromDir , basePath ) ;
167171 const rebased = encodeUrlPath ( relative ( resolve ( toDir ) , absolutePath ) . split ( sep ) . join ( "/" ) ) ;
168172 return appendSuffixToUrl ( rebased , suffix ) ;
169173}
0 commit comments