10000 Correctly handle data URIs, add test for quoted data URIs. · websdotcom/less.js@5ad3a67 · GitHub
[go: up one dir, main page]

Skip to content

Commit 5ad3a67

Browse files
committed
Correctly handle data URIs, add test for quoted data URIs.
1 parent 198f7c9 commit 5ad3a67

File tree

3 files changed

+8
-1
lines changed

3 files changed

+8
-1
lines changed

lib/less/tree/url.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ tree.URL = function (val, paths) {
55
this.attrs = val;
66
} else {
77
// Add the base path if the URL is relative and we are in the browser
8-
if (!/^(?:https?:\/|file:\/|data:\/)?\//.test(val.value) && paths.length > 0 && typeof(window) !== 'undefined') {
8+
if (!/^(?:https?:\/\/|file:\/\/|data:)?/.test(val.value) && paths.length > 0 && typeof(window) !== 'undefined') {
99
val.value = paths[0] + (val.value.charAt(0) === '/' ? val.value.slice(1) : val.value);
1010
}
1111
this.value = val;

test/css/css.css

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,3 +80,6 @@ p + h1 {
8080
kg9C9zwz3gVLMDA/A6P9/AFGGFyjOXZtQAAAAAElFTkSuQmCC);
8181
background-image: url(data:image/x-png,f9difSSFIIGFIFJD1f982FSDKAA9==);
8282
}
83+
#svg-data-uri {
84+
background: transparent url('data:image/svg+xml, <svg version="1.1"><g></g></svg>');
85+
}

test/less/css.less

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,3 +94,7 @@ p + h1 {
9494
kg9C9zwz3gVLMDA/A6P9/AFGGFyjOXZtQAAAAAElFTkSuQmCC);
9595
background-image: url(data:image/x-png,f9difSSFIIGFIFJD1f982FSDKAA9==);
9696
}
97+
98+
#svg-data-uri {
99+
background: transparent url('data:image/svg+xml, <svg version="1.1"><g></g></svg>');
100+
}

0 commit comments

Comments
 (0)
0