Skip to content

Commit

Permalink
Feature: escape deps url on CSSPackager
Browse files Browse the repository at this point in the history
  • Loading branch information
Shinyaigeek committed Mar 20, 2022
1 parent 96c847b commit 483258c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
3 changes: 3 additions & 0 deletions packages/core/utils/src/replaceBundleReferences.js
Expand Up @@ -191,6 +191,9 @@ export function getURLReplacement({

let placeholder = dependency.meta?.placeholder ?? dependency.id;
invariant(typeof placeholder === 'string');

to = to.replace(/"/g, '\\"');

return {
from: placeholder,
to,
Expand Down
13 changes: 8 additions & 5 deletions packages/transformers/css/src/CSSTransformer.js
Expand Up @@ -83,12 +83,15 @@ export default (new Transformer({
symbols: new Map([['*', {local: '*', isWeak: true, loc}]]),
});
} else if (dep.type === 'url') {
asset.addURLDependency(dep.url, {
loc,
meta: {
placeholder: dep.placeholder,
asset.addURLDependency(
dep.url.replace(/\\"/g, '"').replace(/\\'/g, "'"),
{
loc,
meta: {
placeholder: dep.placeholder,
},
},
});
);
}
}
}
Expand Down

0 comments on commit 483258c

Please sign in to comment.