Skip to content

Commit

Permalink
v0.1.18: fix Packet.fromBase64
Browse files Browse the repository at this point in the history
  • Loading branch information
taichunmin committed May 16, 2023
1 parent 854651e commit b6d197d
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"name": "pn532.js",
"type": "module",
"unpkg": "dist/pn532.min.js",
"version": "0.1.17",
"version": "0.1.18",
"bugs": {
"url": "https://github.com/taichunmin/pn532.js/issues"
},
Expand Down
2 changes: 1 addition & 1 deletion src/Packet.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ export default class Packet extends Uint8Array {
base64 = `${base64}AAA`.slice(0, tmp2 - tmp2 % 4)
const pack = new Packet(base64.length * 3 >>> 2)
let parsedLen = 0
for (let i = 0; i < base64.length; i++) {
for (let i = 0; i < base64.length; i += 4) {
const u24 = (BASE64_CHAR.get(base64[i]) << 18) +
(BASE64_CHAR.get(base64[i + 1]) << 12) +
(BASE64_CHAR.get(base64[i + 2]) << 6) +
Expand Down
2 changes: 2 additions & 0 deletions src/Packet.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,7 @@ test.each([
['MQ', 'MQ'],
['MTI', 'MTI'],
['MTIz', 'MTIz'],
['SGVs/G8+d29ybGQ', 'SGVs_G8-d29ybGQ'],
])('Packet.fromBase64(%j).base64url = %j', async (hex, expected) => {
const actual = Packet.fromBase64(hex).base64url
expect(actual).toEqual(expected)
Expand All @@ -239,6 +240,7 @@ test.each([
['MQ', 'MQ=='],
['MTI', 'MTI='],
['MTIz', 'MTIz'],
['SGVs_G8-d29ybGQ', 'SGVs/G8+d29ybGQ='],
])('Packet.fromBase64(%j).base64 = %j', async (hex, expected) => {
const actual = Packet.fromBase64(hex).base64
expect(actual).toEqual(expected)
Expand Down

0 comments on commit b6d197d

Please sign in to comment.