Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

magnet-uri

Package Overview
Dependencies
Maintainers
8
Versions
46
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

magnet-uri - npm Package Compare versions

Comparing version 6.1.1 to 6.2.0

18

index.js

@@ -74,2 +74,4 @@ /*! magnet-uri. MIT License. WebTorrent LLC <https://webtorrent.io/opensource> */

result.infoHash = Buffer.from(decodedStr, 'binary').toString('hex')
} else if ((m = xt.match(/^urn:btmh:1220(.{64})/))) {
result.infoHashV2 = m[1].toLowerCase()
}

@@ -89,2 +91,3 @@ })

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')

@@ -126,4 +129,15 @@

// (example: `infoHash` for `xt`, `name` for `dn`)
if (obj.infoHashBuffer) obj.xt = `urn:btih:${obj.infoHashBuffer.toString('hex')}`
if (obj.infoHash) obj.xt = `urn:btih:${obj.infoHash}`
// Deduplicate xt by using a set
let xts = new Set()
if (obj.xt && typeof obj.xt === 'string') xts.add(obj.xt)
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.infoHash) xts.add(`urn:btih:${obj.infoHash}`)
if (obj.infoHashV2Buffer) xts.add(obj.xt = `urn:btmh:1220${obj.infoHashV2Buffer.toString('hex')}`)
if (obj.infoHashV2) xts.add(`urn:btmh:1220${obj.infoHashV2}`)
const xtsDeduped = Array.from(xts)
if (xtsDeduped.length === 1) obj.xt = xtsDeduped[0]
if (xtsDeduped.length > 1) obj.xt = xtsDeduped
if (obj.publicKeyBuffer) obj.xs = `urn:btpk:${obj.publicKeyBuffer.toString('hex')}`

@@ -130,0 +144,0 @@ if (obj.publicKey) obj.xs = `urn:btpk:${obj.publicKey}`

6

package.json
{
"name": "magnet-uri",
"description": "Parse a magnet URI and return an object of keys/values",
"version": "6.1.1",
"version": "6.2.0",
"author": {

@@ -14,3 +14,3 @@ "name": "WebTorrent LLC",

"dependencies": {
"bep53-range": "^1.0.0",
"bep53-range": "^1.1.0",
"thirty-two": "^1.0.2"

@@ -20,3 +20,3 @@ },

"standard": "*",
"tape": "^5.0.1"
"tape": "^5.2.2"
},

@@ -23,0 +23,0 @@ "funding": [

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc