Socket
Socket
Sign inDemoInstall

magnet-uri

Package Overview
Dependencies
Maintainers
7
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.0.0 to 6.1.0

.github/workflows/ci.yml

19

index.js

@@ -77,3 +77,14 @@ /*! magnet-uri. MIT License. WebTorrent LLC <https://webtorrent.io/opensource> */

}
if (result.xs) {
const xss = Array.isArray(result.xs) ? result.xs : [result.xs]
xss.forEach(xs => {
if ((m = xs.match(/^urn:btpk:(.{64})/))) {
result.publicKey = m[1].toLowerCase()
}
})
}
if (result.infoHash) result.infoHashBuffer = Buffer.from(result.infoHash, 'hex')
if (result.publicKey) result.publicKeyBuffer = Buffer.from(result.publicKey, 'hex')

@@ -116,2 +127,4 @@ if (result.dn) result.name = result.dn

if (obj.infoHash) obj.xt = `urn:btih:${obj.infoHash}`
if (obj.publicKeyBuffer) obj.xs = `urn:btpk:${obj.publicKeyBuffer.toString('hex')}`
if (obj.publicKey) obj.xs = `urn:btpk:${obj.publicKey}`
if (obj.name) obj.dn = obj.name

@@ -135,5 +148,9 @@ if (obj.keywords) obj.kt = obj.keywords

if (key === 'dn') val = encodeURIComponent(val).replace(/%20/g, '+')
if (key === 'tr' || key === 'xs' || key === 'as' || key === 'ws') {
if (key === 'tr' || key === 'as' || key === 'ws') {
val = encodeURIComponent(val)
}
// Don't URI encode BEP46 keys
if (key === 'xs' && !val.startsWith('urn:btpk:')) {
val = encodeURIComponent(val)
}
if (key === 'kt') val = encodeURIComponent(val)

@@ -140,0 +157,0 @@ if (key === 'so') return

2

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

@@ -6,0 +6,0 @@ "name": "WebTorrent LLC",

@@ -103,3 +103,3 @@ # magnet-uri [![travis][travis-image]][travis-url] [![npm][npm-image]][npm-url] [![downloads][downloads-image]][downloads-url] [![javascript style guide][standard-image]][standard-url]

You can also use convenience key names like `name` (`dn`), `infoHash` (`xt`),
`infoHashBuffer` (`xt`), `announce` (`tr`), and `keywords` (`kt`).
`infoHashBuffer` (`xt`), `publicKey` (`xs`), `publicKeyBuffer` (`xs`), `announce` (`tr`), and `keywords` (`kt`).

@@ -106,0 +106,0 @@ ## license

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