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
3 changes: 3 additions & 0 deletions lib/url/escape.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
module.exports = function escape(url) {
if (typeof url !== 'string') {
return url
}
// If url is already wrapped in quotes, remove them
if (/^['"].*['"]$/.test(url)) {
url = url.slice(1, -1);
Expand Down
2 changes: 1 addition & 1 deletion test/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ function getEvaluated(output, modules) {
return require("../lib/url/escape");
if(module.indexOf("-!/path/css-loader!") === 0)
module = module.substr(19);
if(modules && modules[module])
if(modules && module in modules)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why in?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@evilebottnawi: To allow for falsy modules such as { './module': null } to still be resolved.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kgram thanks for clafiry 👍

return modules[module];
return "{" + module + "}";
});
Expand Down
6 changes: 6 additions & 0 deletions test/urlTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,12 @@ describe("url", function() {
test("module from url-loader", ".class { background: green url(module) xyz }", [
[1, ".class { background: green url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAA) xyz }", ""]
], "", { './module': "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAA" });
test("module from null-loader (empty object from webpack)", ".class { background: green url(module) xyz }", [
[1, ".class { background: green url([object Object]) xyz }", ""]
], "", { './module': {} });
test("module is null", ".class { background: green url(module) xyz }", [
[1, ".class { background: green url(null) xyz }", ""]
], "", { './module': null });

test("background img with url", ".class { background: green url( \"img.png\" ) xyz }", [
[1, ".class { background: green url( \"img.png\" ) xyz }", ""]
Expand Down