Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -693,4 +693,17 @@ describe('Browser Builder styles', () => {

await browserBuild(architect, host, target, { styles: ['src/styles.css'] });
});

it('works when Data URI has escaped quote', async () => {
const svgData = `"data:image/svg+xml;charset=utf-8,<svg width=/"16/" height=/"15/"></svg>"`;

host.writeMultipleFiles({
'src/styles.css': `
div { background: url(${svgData}) }
`,
});

const result = await browserBuild(architect, host, target, { styles: ['src/styles.css'] });
expect(await result.files['styles.css']).toContain(svgData);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ export default function (options?: PostcssCliResourcesOptions): Plugin {
}

const value = decl.value;
const urlRegex = /url\(\s*(?:"([^"]+)"|'([^']+)'|(.+?))\s*\)/g;
const urlRegex = /url(?:\(\s*['"]?)(.*?)(?:['"]?\s*\))/g;
const segments: string[] = [];

let match;
Expand All @@ -168,7 +168,7 @@ export default function (options?: PostcssCliResourcesOptions): Plugin {

// eslint-disable-next-line no-cond-assign
while ((match = urlRegex.exec(value))) {
const originalUrl = match[1] || match[2] || match[3];
const originalUrl = match[1];
let processedUrl;
try {
processedUrl = await process(originalUrl, context, resourceCache);
Expand Down