Support all three Swarm URIs

This commit is contained in:
Alex Beregszaszi 2017-02-23 00:53:29 +00:00
parent b707c9ae53
commit 83dc72ec83
1 changed files with 2 additions and 6 deletions

View File

@ -4,12 +4,8 @@ function isValidHash (hash) {
return /^[0-9a-f]{64}$/.test(hash)
}
function getFile (hash, cb) {
if (!isValidHash(hash)) {
return cb('Invalid hash')
}
request('http://swarm-gateways.net/bzzr:/' + hash, function (error, response, body) {
function getFile (url, cb) {
request('http://swarm-gateways.net/' + url, function (error, response, body) {
if (!error & response.statusCode === 200) {
cb(null, body)
} else {