ipns-ipfs: moving away from bracket object notations (ref. #12, #13)

merge-requests/9/merge
Michał 'rysiek' Woźniak 2021-09-08 23:17:20 +00:00
rodzic 65708a129d
commit 40e2c9ddef
1 zmienionych plików z 7 dodań i 7 usunięć

Wyświetl plik

@ -205,7 +205,7 @@
console.log("Adding to IPFS...")
console.log("+-- number of resources:", resources.length)
var ipfs_addresses = {};
var ipfs_addresses = new Map();
resources.forEach(function(res){
console.log(" +-- handling internal resource:", res)
@ -217,10 +217,10 @@
// res holds the full URL
// what we need in ipfs_addresses is in fact the absolute path (no domain, no scheme)
var abs_path = res.replace(window.location.origin, '')
ipfs_addresses[abs_path] = '/ipfs/' + result.cid.string
console.log("Added to IPFS: " + abs_path + ' as ' + ipfs_addresses[abs_path])
ipfs_addresses.set(abs_path, '/ipfs/' + result.cid.string)
console.log("Added to IPFS: " + abs_path + ' as ' + ipfs_addresses.get(abs_path))
// if we seem to have all we need, resolve!
if (Object.keys(ipfs_addresses).length === resources.length) resolve(ipfs_addresses);
if (ipfs_addresses.size === resources.length) resolve(ipfs_addresses);
})
});
@ -254,10 +254,10 @@
console.log('Checking IPFS content against a gateway...')
console.log('+-- gateway in use: ' + config.ipfsGateway)
// get the list of IPFS addresses
var updatedPaths = Object.values(ipfs_addresses)
for (path in ipfs_addresses) {
var updatedPaths = Array.from(ipfs_addresses.values())
for (const path of ipfs_addresses.keys()) {
// start the fetch
fetch(config.ipfsGateway + ipfs_addresses[path])
fetch(config.ipfsGateway + ipfs_addresses.get(path))
.then((response) => {
ipfsaddr = response.url.replace(config.ipfsGateway, '')
if (response.ok) {