Support all three Swarm URIs
This commit is contained in:
parent
b707c9ae53
commit
83dc72ec83
8
index.js
8
index.js
|
@ -4,12 +4,8 @@ function isValidHash (hash) {
|
||||||
return /^[0-9a-f]{64}$/.test(hash)
|
return /^[0-9a-f]{64}$/.test(hash)
|
||||||
}
|
}
|
||||||
|
|
||||||
function getFile (hash, cb) {
|
function getFile (url, cb) {
|
||||||
if (!isValidHash(hash)) {
|
request('http://swarm-gateways.net/' + url, function (error, response, body) {
|
||||||
return cb('Invalid hash')
|
|
||||||
}
|
|
||||||
|
|
||||||
request('http://swarm-gateways.net/bzzr:/' + hash, function (error, response, body) {
|
|
||||||
if (!error & response.statusCode === 200) {
|
if (!error & response.statusCode === 200) {
|
||||||
cb(null, body)
|
cb(null, body)
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in New Issue