Skip to content

Commit

Permalink
Fix: Safari does not accept document.baseURI for cookie path
Browse files Browse the repository at this point in the history
  • Loading branch information
nfam committed Oct 11, 2019
1 parent 72f1a22 commit e41cea6
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion internal/view/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@
return response;
}).then(() => {
localStorage.removeItem("shiori-account");
document.cookie = `session-id=; Path=${document.baseURI}; Expires=Thu, 01 Jan 1970 00:00:00 GMT;`;
document.cookie = `session-id=; Path=${new URL(document.baseURI).pathname}; Expires=Thu, 01 Jan 1970 00:00:00 GMT;`;
location.href = new URL("login", document.baseURI);
}).catch(err => {
this.dialog.loading = false;
Expand Down
4 changes: 2 additions & 2 deletions internal/view/login.html
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@
}

// Remove old cookie
document.cookie = `session-id=; Path=${document.baseURI}; Expires=Thu, 01 Jan 1970 00:00:00 GMT;`;
document.cookie = `session-id=; Path=${new URL(document.baseURI).pathname}; Expires=Thu, 01 Jan 1970 00:00:00 GMT;`;

// Send request
this.loading = true;
Expand All @@ -99,7 +99,7 @@
}).then(json => {
// Save session id
var expTime = new Date(Date.now() + sessionAge * 3600 * 1000).toUTCString();
document.cookie = `session-id=${json.session}; Path=${document.baseURI}; Expires=${expTime}`;
document.cookie = `session-id=${json.session}; Path=${new URL(document.baseURI).pathname}; Expires=${expTime}`;

// Save account data
localStorage.setItem("shiori-account", JSON.stringify(json.account));
Expand Down

0 comments on commit e41cea6

Please sign in to comment.