webdb
webdb copied to clipboard
Trailing "/" inconsistency for dat URLs
When indexing DBs, if you do:
async () => {
await webdb.indexArchive('dat://232ac2ce8ad4ed80bd1b6de4cbea7d7b0cad1441fa62312c57a6088394717e41/');
console.log(await webdb.listSources());
}
You will see ["dat://232ac2ce8ad4ed80bd1b6de4cbea7d7b0cad1441fa62312c57a6088394717e41"]
in your console (note, no trailing /
).
If you do this:
...
console.log(webdb.isSource('dat://232ac2ce8ad4ed80bd1b6de4cbea7d7b0cad1441fa62312c57a6088394717e41/');
...
You will see false
, because the /
at the end is missing. It seems like isSource
does an exact string match, when the thing that's important is the dat hash.
A little thing, but it was throwing me off for a bit :)
Any thoughts? It's simple enough, I might make another PR for this unless you have any objections...
Yeah that's not right. We should "normalize" the URLs as they get stored/passed into WebDB so that the trailing slash is consistent.