magnet-uri
Advanced tools
Comparing version 5.4.0 to 6.0.0
30
index.js
@@ -64,9 +64,2 @@ /*! magnet-uri. MIT License. WebTorrent LLC <https://webtorrent.io/opensource> */ | ||
if (result['x.pe']) { | ||
// remove duplicates and convert to array | ||
result['x.pe'] = Array.isArray(result['x.pe']) | ||
? Array.from(new Set(result['x.pe'])) | ||
: [result['x.pe']] | ||
} | ||
// Convenience properties for parity with `parse-torrent-file` module | ||
@@ -89,7 +82,7 @@ let m | ||
if (result.kt) result.keywords = result.kt | ||
if (result['x.pe']) result.peerAddresses = result['x.pe'] | ||
if (typeof result.tr === 'string') result.announce = [result.tr] | ||
else if (Array.isArray(result.tr)) result.announce = result.tr | ||
else result.announce = [] | ||
result.announce = [] | ||
if (typeof result.tr === 'string' || Array.isArray(result.tr)) { | ||
result.announce = result.announce.concat(result.tr) | ||
} | ||
@@ -104,12 +97,12 @@ result.urlList = [] | ||
result.peerAddresses = [] | ||
if (typeof result['x.pe'] === 'string' || Array.isArray(result['x.pe'])) { | ||
result.peerAddresses = result.peerAddresses.concat(result['x.pe']) | ||
} | ||
// remove duplicates by converting to Set and back | ||
result.announce = Array.from(new Set(result.announce)) | ||
result.urlList = Array.from(new Set(result.urlList)) | ||
result.peerAddresses = Array.from(new Set(result.peerAddresses)) | ||
// convert x.pe into two level object | ||
if (result['x.pe']) { | ||
result.x = { pe: result['x.pe'] } | ||
delete result['x.pe'] | ||
} | ||
return result | ||
@@ -134,5 +127,2 @@ } | ||
// translate x.pe for processing | ||
if (obj.x && obj.x.pe) obj['x.pe'] = obj.x.pe | ||
let result = 'magnet:?' | ||
@@ -139,0 +129,0 @@ Object.keys(obj) |
{ | ||
"name": "magnet-uri", | ||
"description": "Parse a magnet URI and return an object of keys/values", | ||
"version": "5.4.0", | ||
"version": "6.0.0", | ||
"author": { | ||
@@ -6,0 +6,0 @@ "name": "WebTorrent LLC", |
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
10548
119