Skip to content

Commit

Permalink
fix: replace 32 with maintained version (#73)
Browse files Browse the repository at this point in the history
  • Loading branch information
ThaUnknown committed May 30, 2023
1 parent 005f1a6 commit 2c041f4
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
7 changes: 3 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*! magnet-uri. MIT License. WebTorrent LLC <https://webtorrent.io/opensource> */
import base32 from 'thirty-two'
import { decode } from '@thaunknown/thirty-two'
import { parse, compose } from 'bep53-range'
import { hex2arr, arr2hex, bin2hex } from 'uint8-util'
import { hex2arr, arr2hex } from 'uint8-util'

/**
* Parse a magnet URI and return an object of keys/values
Expand Down Expand Up @@ -66,8 +66,7 @@ function magnetURIDecode (uri) {
if ((m = xt.match(/^urn:btih:(.{40})/))) {
result.infoHash = m[1].toLowerCase()
} else if ((m = xt.match(/^urn:btih:(.{32})/))) {
const decodedStr = base32.decode(m[1])
result.infoHash = bin2hex(decodedStr.toString('binary'))
result.infoHash = arr2hex(decode(m[1]))
} else if ((m = xt.match(/^urn:btmh:1220(.{64})/))) {
result.infoHashV2 = m[1].toLowerCase()
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
},
"type": "module",
"dependencies": {
"@thaunknown/thirty-two": "^1.0.3",
"bep53-range": "^2.0.0",
"thirty-two": "^1.0.2",
"uint8-util": "^2.1.9"
},
"devDependencies": {
Expand Down

0 comments on commit 2c041f4

Please sign in to comment.