magnet-uri
Advanced tools
Comparing version 5.0.0 to 5.1.0
@@ -63,3 +63,3 @@ module.exports = magnetURIDecode | ||
if ((m = xt.match(/^urn:btih:(.{40})/))) { | ||
result.infoHash = new Buffer(m[1], 'hex').toString('hex') | ||
result.infoHash = m[1] | ||
} else if ((m = xt.match(/^urn:btih:(.{32})/))) { | ||
@@ -71,2 +71,3 @@ var decodedStr = base32.decode(m[1]) | ||
} | ||
if (result.infoHash) result.infoHashBuffer = new Buffer(result.infoHash, 'hex') | ||
@@ -96,4 +97,5 @@ if (result.dn) result.name = result.dn | ||
// support official magnet key names and convenience names | ||
// support using convenience names, in addition to spec names | ||
// (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 | ||
@@ -100,0 +102,0 @@ if (obj.name) obj.dn = obj.name |
{ | ||
"name": "magnet-uri", | ||
"description": "Parse a magnet URI and return an object of keys/values", | ||
"version": "5.0.0", | ||
"version": "5.1.0", | ||
"author": { | ||
@@ -14,3 +14,3 @@ "name": "Feross Aboukhadijeh", | ||
"dependencies": { | ||
"thirty-two": "^0.0.2", | ||
"thirty-two": "^1.0.1", | ||
"uniq": "^1.0.1", | ||
@@ -20,3 +20,3 @@ "xtend": "^4.0.0" | ||
"devDependencies": { | ||
"standard": "^3.1.2", | ||
"standard": "^5.4.1", | ||
"tape": "^4.0.0", | ||
@@ -47,6 +47,3 @@ "zuul": "^3.0.0" | ||
"test-node": "tape test/*.js" | ||
}, | ||
"testling": { | ||
"files": "test/*.js" | ||
} | ||
} |
@@ -56,2 +56,3 @@ # magnet-uri [![travis][travis-image]][travis-url] [![npm][npm-image]][npm-url] [![downloads][downloads-image]][downloads-url] | ||
"infoHash": "d2474e86c95b19b8bcfdb92bc12c9d44667cfa36", | ||
"infoHashBuffer": ..., | ||
"name": "Leaves of Grass by Walt Whitman.epub", | ||
@@ -103,3 +104,3 @@ "announce": [ | ||
You can also use convenience key names like `name` (`dn`), `infoHash` (`xt`), | ||
`announce` (`tr`), `announceList` (`tr`), and `keywords` (`kt`). | ||
`infoHashBuffer` (`xt`), `announce` (`tr`), and `keywords` (`kt`). | ||
@@ -106,0 +107,0 @@ ## license |
@@ -33,2 +33,3 @@ var magnet = require('../') | ||
infoHash: 'd2474e86c95b19b8bcfdb92bc12c9d44667cfa36', | ||
infoHashBuffer: new Buffer('d2474e86c95b19b8bcfdb92bc12c9d44667cfa36', 'hex'), | ||
tr: [ | ||
@@ -64,1 +65,17 @@ 'udp://open.demonii.com:1337', | ||
}) | ||
test('encode: using infoHashBuffer', function (t) { | ||
var obj = { | ||
infoHashBuffer: new Buffer('d2474e86c95b19b8bcfdb92bc12c9d44667cfa36', 'hex') | ||
} | ||
var result = magnet.encode(obj) | ||
t.equal(result, 'magnet:?xt=urn:btih:d2474e86c95b19b8bcfdb92bc12c9d44667cfa36') | ||
t.deepEqual(magnet.decode(result), { | ||
infoHashBuffer: new Buffer('d2474e86c95b19b8bcfdb92bc12c9d44667cfa36', 'hex'), | ||
infoHash: 'd2474e86c95b19b8bcfdb92bc12c9d44667cfa36', | ||
xt: 'urn:btih:d2474e86c95b19b8bcfdb92bc12c9d44667cfa36', | ||
urlList: [], | ||
announce: [] | ||
}) | ||
t.end() | ||
}) |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
295
108
19264
8
+ Addedthirty-two@1.0.2(transitive)
- Removedthirty-two@0.0.2(transitive)
Updatedthirty-two@^1.0.1