diff --git a/src/index.js b/src/index.js index 508a210..e72a0f6 100644 --- a/src/index.js +++ b/src/index.js @@ -116,13 +116,14 @@ class HlsjsIPFSLoader { }, console.error) } } + async function getFile(ipfs, rootHash, filename, options, debug, abortFlag) { - debug(`Fetching hash for '${rootHash}/${filename}'`) - const path = `${rootHash}/${filename}` + debug(`Fetching hash for '${ rootHash ? `${ rootHash }/` : ""}${ filename }'`); + const path = `${ rootHash ? `${ rootHash }/` : "" }${ filename }`; try { return await cat(path, options, ipfs, debug, abortFlag) } catch(ex) { - throw new Error(`File not found: ${rootHash}/${filename}`) + throw new Error(`File not found: ${ rootHash ? `${ rootHash }/` : "" }${filename}`) } }