fix(compiler): ignore @import in multi-line css (#18452)

Fixes #18038
This commit is contained in:
Marc Laval 2017-08-03 20:00:38 +02:00 committed by Victor Berchet
parent 333a708bb6
commit 1dca575701
2 changed files with 5 additions and 1 deletions

View File

@ -43,5 +43,5 @@ export function extractStyleUrls(
} }
const CSS_IMPORT_REGEXP = /@import\s+(?:url\()?\s*(?:(?:['"]([^'"]*))|([^;\)\s]*))[^;]*;?/g; const CSS_IMPORT_REGEXP = /@import\s+(?:url\()?\s*(?:(?:['"]([^'"]*))|([^;\)\s]*))[^;]*;?/g;
const CSS_COMMENT_REGEXP = /\/\*.+?\*\//g; const CSS_COMMENT_REGEXP = /\/\*[\s\S]+?\*\//g;
const URL_WITH_SCHEMA_REGEXP = /^([^:/?#]+):/; const URL_WITH_SCHEMA_REGEXP = /^([^:/?#]+):/;

View File

@ -40,11 +40,15 @@ export function main() {
const css = ` const css = `
@import '1.css'; @import '1.css';
/*@import '2.css';*/ /*@import '2.css';*/
/*
@import '3.css';
*/
`; `;
const styleWithImports = extractStyleUrls(urlResolver, 'http://ng.io', css); const styleWithImports = extractStyleUrls(urlResolver, 'http://ng.io', css);
expect(styleWithImports.style.trim()).toEqual(''); expect(styleWithImports.style.trim()).toEqual('');
expect(styleWithImports.styleUrls).toContain('http://ng.io/1.css'); expect(styleWithImports.styleUrls).toContain('http://ng.io/1.css');
expect(styleWithImports.styleUrls).not.toContain('http://ng.io/2.css'); expect(styleWithImports.styleUrls).not.toContain('http://ng.io/2.css');
expect(styleWithImports.styleUrls).not.toContain('http://ng.io/3.css');
}); });
it('should extract "@import url()" urls', () => { it('should extract "@import url()" urls', () => {