Skip to content

Commit

Permalink
Compute unique collection id using full sourceUrl if relative url giv…
Browse files Browse the repository at this point in the history
…en (#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
  • Loading branch information
ikreymer authored Jun 15, 2023
1 parent 99a034a commit b26f4b0
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 5 deletions.
3 changes: 3 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
## CHANGES

v1.8.1
- Loading: Resolve sourceUrl to absolute url when computing default id

v1.8.0
- UI: Add 'Show All Pages' option to show non-seed pages that are previously only available via search
- Embeds: add 'swName' option to allow customizing 'sw.js' to a different filename
Expand Down
2 changes: 1 addition & 1 deletion _data/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "replaywebpage",
"productName": "ReplayWeb.page",
"version": "1.8.0",
"version": "1.8.1",
"description": "Serverless Web Archive Replay",
"repository": "https://github.com/webrecorder/replayweb.page",
"homepage": "https://replayweb.page/",
Expand Down
2 changes: 1 addition & 1 deletion embed.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
</head>
<body>

<replay-web-page swname="custom.js" replaybase="./" embed="replay-with-info" src="./docs/assets/tweet-example.wacz" url="page:0"></replay-web-page>
<replay-web-page replaybase="./" embed="replay-with-info" src="./docs/assets/tweet-example.wacz" url="page:0"></replay-web-page>

</body>
</html>
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "replaywebpage",
"productName": "ReplayWeb.page",
"version": "1.8.0",
"version": "1.8.1",
"description": "Serverless Web Archive Replay",
"repository": "https://github.com/webrecorder/replayweb.page",
"homepage": "https://replayweb.page/",
Expand Down
7 changes: 7 additions & 0 deletions src/pageutils.js
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down
4 changes: 2 additions & 2 deletions ui.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit b26f4b0

Please sign in to comment.