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:
@@ -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};
|
||||
|
||||
Reference in New Issue
Block a user