Compute unique collection id using full sourceUrl if relative url given (#179)

* loading: update sourceToId to resolve any pathname to absolute URL (via document.baseURI) for computing unique id (eg. to avoid conflicts of two 'webarchive.wacz' loaded from different paths) - matches behavior used in embed
embed demo: fix typo, don't change default service worker name
This commit is contained in:
Ilya Kreymer
2023-06-15 09:45:01 -07:00
committed by GitHub
parent 99a034af49
commit b26f4b082d
6 changed files with 15 additions and 5 deletions
+7
View File
@@ -60,6 +60,13 @@ function getReplayLink(view, url, ts) {
// ===========================================================================
async function sourceToId(url) {
try {
new URL(url);
} catch (e) {
// if source is not a valid url, resolve as relative filename to current URL
url = new URL(url, document.baseURI).href;
}
const digest = await digestMessage(url, "SHA-256");
const coll = "id-" + digest.slice(0, 12);
return {url, coll};