diff --git a/src/snapshot.ts b/src/snapshot.ts index 27b882be..f412cbfd 100644 --- a/src/snapshot.ts +++ b/src/snapshot.ts @@ -69,7 +69,7 @@ function extractOrigin(url: string): string { return origin; } -const URL_IN_CSS_REF = /url\((?:(')([^']*)'|(")([^"]*)"|([^)]*))\)/gm; +const URL_IN_CSS_REF = /url\((?:(')([^']*)'|(")(.*?)"|([^)]*))\)/gm; const RELATIVE_PATH = /^(?!www\.|(?:http|ftp)s?:\/\/|[A-Za-z]:\\|\/\/|#).*/; const DATA_URI = /^(data:)([^,]*),(.*)/i; export function absoluteToStylesheet( diff --git a/test/__snapshots__/integration.ts.snap b/test/__snapshots__/integration.ts.snap index afa7b2a0..cd30b31c 100644 --- a/test/__snapshots__/integration.ts.snap +++ b/test/__snapshots__/integration.ts.snap @@ -297,7 +297,7 @@ exports[`[html file]: with-style-sheet.html 1`] = ` with style sheet - + " `; @@ -308,7 +308,7 @@ exports[`[html file]: with-style-sheet-with-import.html 1`] = ` with style sheet with import - + " `; diff --git a/test/css/style.css b/test/css/style.css index fe10f55d..2b3faf2a 100644 --- a/test/css/style.css +++ b/test/css/style.css @@ -1,6 +1,7 @@ body { margin: 0; background: url('../a.jpg'); + border-image: url('data:image/svg+xml;utf8,'); } p { color: red; diff --git a/test/snapshot.test.ts b/test/snapshot.test.ts index 025fac6c..4d96a02b 100644 --- a/test/snapshot.test.ts +++ b/test/snapshot.test.ts @@ -89,6 +89,14 @@ describe('absolute url to stylesheet', () => { ).to.equal( 'url(\'data:image/svg+xml;utf8,\')', ); + expect( + absoluteToStylesheet( + 'url("data:image/svg+xml;utf8,")', + href, + ), + ).to.equal( + 'url("data:image/svg+xml;utf8,")', + ); }); it('can handle empty path', () => { expect(absoluteToStylesheet(`url('')`, href)).to.equal(`url('')`);