Fragment handling in data-uri function 1959

The change removes #fragment from filePath before readig the file and adds
it back to the end of the generated uri.
This commit is contained in:
jurcovicovam
2014-08-03 13:20:02 +02:00
parent 169bbada40
commit 37ae8c4adb
3 changed files with 11 additions and 2 deletions

View File

@@ -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));
},