Socket
Socket
Sign inDemoInstall

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 5.2.4 to 5.3.0

22

index.js

@@ -0,1 +1,2 @@

/*! magnet-uri. MIT License. WebTorrent LLC <https://webtorrent.io/opensource> */
module.exports = magnetURIDecode

@@ -6,3 +7,2 @@ module.exports.decode = magnetURIDecode

const base32 = require('thirty-two')
const uniq = require('uniq')

@@ -51,8 +51,7 @@ /**

if (result[key]) {
if (Array.isArray(result[key])) {
result[key].push(val)
} else {
const old = result[key]
result[key] = [old, val]
if (!Array.isArray(result[key])) {
result[key] = [result[key]]
}
result[key].push(val)
} else {

@@ -66,3 +65,3 @@ result[key] = val

if (result.xt) {
const xts = Array.isArray(result.xt) ? result.xt : [ result.xt ]
const xts = Array.isArray(result.xt) ? result.xt : [result.xt]
xts.forEach(xt => {

@@ -82,3 +81,3 @@ if ((m = xt.match(/^urn:btih:(.{40})/))) {

if (typeof result.tr === 'string') result.announce = [ result.tr ]
if (typeof result.tr === 'string') result.announce = [result.tr]
else if (Array.isArray(result.tr)) result.announce = result.tr

@@ -95,4 +94,5 @@ else result.announce = []

uniq(result.announce)
uniq(result.urlList)
// remove duplicates by converting to Set and back
result.announce = Array.from(new Set(result.announce))
result.urlList = Array.from(new Set(result.urlList))

@@ -121,3 +121,3 @@ return result

.forEach((key, i) => {
const values = Array.isArray(obj[key]) ? obj[key] : [ obj[key] ]
const values = Array.isArray(obj[key]) ? obj[key] : [obj[key]]
values.forEach((val, j) => {

@@ -124,0 +124,0 @@ if ((i > 0 || j > 0) && (key !== 'kt' || j === 0)) result += '&'

{
"name": "magnet-uri",
"description": "Parse a magnet URI and return an object of keys/values",
"version": "5.2.4",
"version": "5.3.0",
"author": {
"name": "WebTorrent, LLC",
"name": "WebTorrent LLC",
"email": "feross@webtorrent.io",

@@ -14,8 +14,7 @@ "url": "https://webtorrent.io"

"dependencies": {
"thirty-two": "^1.0.1",
"uniq": "^1.0.1"
"thirty-two": "^1.0.2"
},
"devDependencies": {
"standard": "*",
"tape": "^4.0.0"
"tape": "^5.0.1"
},

@@ -40,3 +39,17 @@ "keywords": [

"test": "standard && tape test/*.js"
}
},
"funding": [
{
"type": "github",
"url": "https://github.com/sponsors/feross"
},
{
"type": "patreon",
"url": "https://www.patreon.com/feross"
},
{
"type": "consulting",
"url": "https://feross.org/support"
}
]
}
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