Skip to content

Commit

Permalink
Use Uint8Array in Base64 decoding
Browse files Browse the repository at this point in the history
Otherwise each element isn't considered a single byte. This breaks
conversion to other types, e.g. Blob.
  • Loading branch information
CendioOssman committed Aug 24, 2018
1 parent cb9478f commit 4a210f9
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion core/base64.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ export default {

/* Every four characters is 3 resulting numbers */
const result_length = (data_length >> 2) * 3 + Math.floor((data_length % 4) / 1.5);
const result = new Array(result_length);
const result = new Uint8Array(result_length);

// Convert one by one.

Expand Down
2 changes: 1 addition & 1 deletion tests/test.base64.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import Base64 from '../core/base64.js';
describe('Base64 Tools', function() {
"use strict";

const BIN_ARR = new Array(256);
const BIN_ARR = new Uint8Array(256);
for (let i = 0; i < 256; i++) {
BIN_ARR[i] = i;
}
Expand Down

0 comments on commit 4a210f9

Please sign in to comment.