magnet-uri
Advanced tools
Comparing version 7.0.0 to 7.0.1
@@ -0,1 +1,8 @@ | ||
## [7.0.1](https://github.com/webtorrent/magnet-uri/compare/v7.0.0...v7.0.1) (2023-01-26) | ||
### Performance Improvements | ||
* drop buffer ([#64](https://github.com/webtorrent/magnet-uri/issues/64)) ([cf98664](https://github.com/webtorrent/magnet-uri/commit/cf98664336bfe813c4d1d55a54229667c01f0962)) | ||
# [7.0.0](https://github.com/webtorrent/magnet-uri/compare/v6.2.0...v7.0.0) (2023-01-26) | ||
@@ -2,0 +9,0 @@ |
15
index.js
/*! magnet-uri. MIT License. WebTorrent LLC <https://webtorrent.io/opensource> */ | ||
import base32 from 'thirty-two' | ||
import { parse, compose } from 'bep53-range' | ||
import { hex2arr, arr2hex, bin2hex } from 'uint8-util' | ||
@@ -69,3 +70,3 @@ /** | ||
const decodedStr = base32.decode(m[1]) | ||
result.infoHash = Buffer.from(decodedStr, 'binary').toString('hex') | ||
result.infoHash = bin2hex(decodedStr) | ||
} else if ((m = xt.match(/^urn:btmh:1220(.{64})/))) { | ||
@@ -86,5 +87,5 @@ result.infoHashV2 = m[1].toLowerCase() | ||
if (result.infoHash) result.infoHashBuffer = Buffer.from(result.infoHash, 'hex') | ||
if (result.infoHashV2) result.infoHashV2Buffer = Buffer.from(result.infoHashV2, 'hex') | ||
if (result.publicKey) result.publicKeyBuffer = Buffer.from(result.publicKey, 'hex') | ||
if (result.infoHash) result.infoHashBuffer = hex2arr(result.infoHash) | ||
if (result.infoHashV2) result.infoHashV2Buffer = hex2arr(result.infoHashV2) | ||
if (result.publicKey) result.publicKeyBuffer = hex2arr(result.publicKey) | ||
@@ -130,5 +131,5 @@ if (result.dn) result.name = result.dn | ||
if (obj.xt && Array.isArray(obj.xt)) xts = new Set(obj.xt) | ||
if (obj.infoHashBuffer) xts.add(`urn:btih:${obj.infoHashBuffer.toString('hex')}`) | ||
if (obj.infoHashBuffer) xts.add(`urn:btih:${arr2hex(obj.infoHashBuffer)}`) | ||
if (obj.infoHash) xts.add(`urn:btih:${obj.infoHash}`) | ||
if (obj.infoHashV2Buffer) xts.add(obj.xt = `urn:btmh:1220${obj.infoHashV2Buffer.toString('hex')}`) | ||
if (obj.infoHashV2Buffer) xts.add(obj.xt = `urn:btmh:1220${arr2hex(obj.infoHashV2Buffer)}`) | ||
if (obj.infoHashV2) xts.add(`urn:btmh:1220${obj.infoHashV2}`) | ||
@@ -139,3 +140,3 @@ const xtsDeduped = Array.from(xts) | ||
if (obj.publicKeyBuffer) obj.xs = `urn:btpk:${obj.publicKeyBuffer.toString('hex')}` | ||
if (obj.publicKeyBuffer) obj.xs = `urn:btpk:${arr2hex(obj.publicKeyBuffer)}` | ||
if (obj.publicKey) obj.xs = `urn:btpk:${obj.publicKey}` | ||
@@ -142,0 +143,0 @@ if (obj.name) obj.dn = obj.name |
{ | ||
"name": "magnet-uri", | ||
"description": "Parse a magnet URI and return an object of keys/values", | ||
"version": "7.0.0", | ||
"version": "7.0.1", | ||
"author": { | ||
@@ -16,3 +16,4 @@ "name": "WebTorrent LLC", | ||
"bep53-range": "^2.0.0", | ||
"thirty-two": "^1.0.2" | ||
"thirty-two": "^1.0.2", | ||
"uint8-util": "^2.1.6" | ||
}, | ||
@@ -19,0 +20,0 @@ "devDependencies": { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
13287
146
0
3
+ Addeduint8-util@^2.1.6
+ Addedbase64-arraybuffer@1.0.2(transitive)
+ Addeduint8-util@2.2.5(transitive)