Skip to content

Commit

Permalink
Parse quoted and unquoted uri @imports. Fixes #108
Browse files Browse the repository at this point in the history
  • Loading branch information
terinjokes committed Mar 13, 2014
1 parent 69e350f commit fbbcab6
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/css/Parser.js
Expand Up @@ -259,7 +259,7 @@ Parser.prototype = function(){
tokenStream.mustMatch([Tokens.STRING, Tokens.URI]);

//grab the URI value
uri = tokenStream.token().value.replace(/(?:url\()?["']([^"']+)["']\)?/, "$1");
uri = tokenStream.token().value.replace(/^(?:url\()?["']?([^"']+?)["']?\)?$/, "$1");

this._readWhitespace();

Expand Down
28 changes: 28 additions & 0 deletions tests/css/Parser.js
Expand Up @@ -1722,6 +1722,34 @@
Assert.areEqual("-moz-inline-stack", event.value.parts[0].text, "Vendor prefixed value -moz-inline-stack is intact.");
});
var result = parser.parse(".foo {\n display: -moz-inline-stack;\n}");
},

"Test @import uri without quotes": function(){
var parser = new Parser({ strict: true});
parser.addListener("import", function(event){
Assert.areEqual("import", event.type);
Assert.areEqual("http://www.yahoo.com", event.uri);
});
var result = parser.parse("@import url(http://www.yahoo.com);");
},


"Test @import uri with quotes": function(){
var parser = new Parser({ strict: true});
parser.addListener("import", function(event){
Assert.areEqual("import", event.type);
Assert.areEqual("http://www.yahoo.com", event.uri);
});
var result = parser.parse("@import url('http://www.yahoo.com');");
},

"Test @import address": function(){
var parser = new Parser();
parser.addListener("import", function(event){
Assert.areEqual("import", event.type);
Assert.areEqual("http://www.yahoo.com", event.uri);
});
var result = parser.parse("@import 'http://www.yahoo.com';");
}
}));

Expand Down

0 comments on commit fbbcab6

Please sign in to comment.