Commit 78468a2d authored by Romain Courteaud's avatar Romain Courteaud

Handle data uri

parent f55aeaf7
......@@ -1053,7 +1053,31 @@
//////////////////////////////////////////////
var default_xhr = $.ajaxSettings.xhr,
dispatch;
dispatch,
dispatch_data;
dispatch_data = function () {
// data:[<mediatype>][;base64],<data>
var regexp = /^data:\/\/([\w\/]+)?(;base64)?,([\w\W]+)/,
mime_type, is_base_64, data;
// window.atob(encodedData);
if (regexp.test(this.url)) {
mime_type = regexp.exec(this.url)[1];
is_base_64 = regexp.exec(this.url)[2];
data = regexp.exec(this.url)[3];
if (is_base_64 === ';base64') {
this.respond(200, {
'Content-Type': mime_type,
}, window.atob(data));
} else {
this.respond(200, {
'Content-Type': mime_type,
}, data);
}
} else {
this.respond(404, {}, "");
}
};
dispatch = function () {
// XXX Local hack
......@@ -1127,6 +1151,9 @@
if (/^browser:\/\//.test(this.url)) {
result = new BrowserHttpRequest();
result.dispatch = dispatch;
} else if (/^data:\/\//.test(this.url)) {
result = new BrowserHttpRequest();
result.dispatch = dispatch_data;
} else {
result = default_xhr();
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment