Commit 1ae98fee by Edgar HIPP

Fix lint

parent 652a7641
......@@ -2,6 +2,7 @@
"parser": "babel-eslint",
"globals":{
"saveAs": true,
"Uint8Array": true,
"JSZipUtils": true
},
"env": {
......
......@@ -114,28 +114,28 @@ function testStart() {
});
it("should work with base64 data", function () {
const base64Image = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAIAAAACUFjqAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAB3RJTUUH4QIJBywfp3IOswAAAB1pVFh0Q29tbWVudAAAAAAAQ3JlYXRlZCB3aXRoIEdJTVBkLmUHAAAAkUlEQVQY052PMQqDQBREZ1f/d1kUm3SxkeAF/FdIjpOcw2vpKcRWCwsRPMFPsaIQSIoMr5pXDGNUFd9j8TOn7kRW71fvO5HTq6qqtnWtzh20IqE3YXtL0zyKwAROQLQ5l/c9gHjfKK6wMZjADE6s49Dver4/smEAc2CuqgwAYI5jU9NcxhHEy60sni986H9+vwG1yDHfK1jitgAAAABJRU5ErkJggg=="
const base64Image = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAIAAAACUFjqAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAB3RJTUUH4QIJBywfp3IOswAAAB1pVFh0Q29tbWVudAAAAAAAQ3JlYXRlZCB3aXRoIEdJTVBkLmUHAAAAkUlEQVQY052PMQqDQBREZ1f/d1kUm3SxkeAF/FdIjpOcw2vpKcRWCwsRPMFPsaIQSIoMr5pXDGNUFd9j8TOn7kRW71fvO5HTq6qqtnWtzh20IqE3YXtL0zyKwAROQLQ5l/c9gHjfKK6wMZjADE6s49Dver4/smEAc2CuqgwAYI5jU9NcxhHEy60sni986H9+vwG1yDHfK1jitgAAAABJRU5ErkJggg==";
this.name = "imageExample.docx";
function base64DataURLToArrayBuffer(dataURL) {
const string_base64 = dataURL.replace(/^data:image\/(png|jpg);base64,/, "");
var binary_string;
const stringBase64 = dataURL.replace(/^data:image\/(png|jpg);base64,/, "");
let binaryString;
if (typeof window !== "undefined") {
binary_string = window.atob(string_base64);
binaryString = window.atob(stringBase64);
}
else {
binary_string = new Buffer(string_base64, 'base64').toString('binary');
binaryString = new Buffer(stringBase64, "base64").toString("binary");
}
var len = binary_string.length;
var bytes = new Uint8Array(len);
for (var i = 0; i < len; i++) {
var ascii = binary_string.charCodeAt(i);
const len = binaryString.length;
const bytes = new Uint8Array(len);
for (let i = 0; i < len; i++) {
const ascii = binaryString.charCodeAt(i);
bytes[i] = ascii;
}
return bytes.buffer;
};
}
this.opts.getImage = function (image) {
return image;
}
};
this.expectedName = "expectedBase64.docx";
this.data = {image: base64DataURLToArrayBuffer(base64Image)};
this.loadAndRender();
......
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