Skip to content

Commit 4d8d17c

Browse files
committed
fix(StyleInliner): add support for url(url) format
1 parent e3f4c60 commit 4d8d17c

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

modules/angular2/src/core/compiler/style_inliner.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,11 +118,11 @@ export class StyleInliner {
118118

119119
// Extracts the url from an import rule, supported formats:
120120
// - 'url' / "url",
121-
// - url('url') / url("url")
121+
// - url(url) / url('url') / url("url")
122122
function _extractUrl(importRule: string): string {
123123
var match = RegExpWrapper.firstMatch(_urlRe, importRule);
124124
if (isBlank(match)) return null;
125-
return match[1];
125+
return isPresent(match[1]) ? match[1] : match[2];
126126
}
127127

128128
// Extracts the media query from an import rule.
@@ -140,5 +140,8 @@ function _wrapInMediaRule(css: string, query: string): string {
140140
}
141141

142142
var _importRe = RegExpWrapper.create('@import\\s+([^;]+);');
143-
var _urlRe = RegExpWrapper.create('(?:url\\(\\s*)?[\'"]([^\'"]+)[\'"]');
143+
var _urlRe = RegExpWrapper.create(
144+
'url\\(\\s*?[\'"]?([^\'")]+)[\'"]?|' + // url(url) or url('url') or url("url")
145+
'[\'"]([^\'")]+)[\'"]' // "url" or 'url'
146+
);
144147
var _mediaQueryRe = RegExpWrapper.create('[\'"][^\'"]+[\'"]\\s*\\)?\\s*(.*)');

modules/angular2/test/core/compiler/style_inliner_spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ export function main() {
4646
});
4747

4848
// TODO(vicb): fix the StyleInliner
49-
xit('should support url([unquoted url]) in @import rules', (done) => {
49+
it('should support url([unquoted url]) in @import rules', (done) => {
5050
xhr.reply('http://base/one.css', '.one {}');
5151
var css = '@import url(one.css);.main {}';
5252
var loadedCss = inliner.inlineImports(css, 'http://base');

0 commit comments

Comments
 (0)