mirror of
https://github.com/less/less.js.git
synced 2026-01-23 22:27:57 -05:00
Merge pull request #2136 from SomMeri/data-uri-1959
Fragment handling in data-uri function 1959
This commit is contained in:
@@ -422,6 +422,13 @@ tree.functions = {
|
||||
filePath = mimetype;
|
||||
}
|
||||
|
||||
var fragmentStart = filePath.indexOf('#');
|
||||
var fragment = '';
|
||||
if (fragmentStart!==-1) {
|
||||
fragment = filePath.slice(fragmentStart);
|
||||
filePath = filePath.slice(0, fragmentStart);
|
||||
}
|
||||
|
||||
if (this.env.isPathRelative(filePath)) {
|
||||
if (this.currentFileInfo.relativeUrls) {
|
||||
filePath = path.join(this.currentFileInfo.currentDirectory, filePath);
|
||||
@@ -470,7 +477,7 @@ tree.functions = {
|
||||
buf = useBase64 ? buf.toString('base64')
|
||||
: encodeURIComponent(buf);
|
||||
|
||||
var uri = "\"data:" + mimetype + ',' + buf + "\"";
|
||||
var uri = "\"data:" + mimetype + ',' + buf + fragment + "\"";
|
||||
return new(tree.URL)(new(tree.Anonymous)(uri));
|
||||
},
|
||||
|
||||
|
||||
@@ -53,6 +53,7 @@
|
||||
}
|
||||
#data-uri {
|
||||
uri: url("data:image/jpeg;base64,bm90IGFjdHVhbGx5IGEganBlZyBmaWxlCg==");
|
||||
uri-fragment: url("data:image/jpeg;base64,bm90IGFjdHVhbGx5IGEganBlZyBmaWxlCg==#fragment");
|
||||
}
|
||||
#data-uri-guess {
|
||||
uri: url("data:image/jpeg;base64,bm90IGFjdHVhbGx5IGEganBlZyBmaWxlCg==");
|
||||
|
||||
@@ -42,6 +42,7 @@
|
||||
|
||||
#data-uri {
|
||||
uri: data-uri('image/jpeg;base64', '../data/image.jpg');
|
||||
uri-fragment: data-uri('image/jpeg;base64', '../data/image.jpg#fragment');
|
||||
}
|
||||
|
||||
#data-uri-guess {
|
||||
@@ -80,4 +81,4 @@
|
||||
src+: format('truetype');
|
||||
src+_: url('webfont.ttf');
|
||||
src+: url('webfont.svg#svgFontName') format('svg');
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user