Skip to content

Commit

Permalink
Merge pull request Tencent#264 from qianxinfeng/dev
Browse files Browse the repository at this point in the history
fix remove cookie fail when it is set path=/ or top domain
  • Loading branch information
Maizify authored Aug 17, 2019
2 parents dd782b7 + 7ddaeac commit c8addd4
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion dist/vconsole.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package-lock.json

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

7 changes: 5 additions & 2 deletions src/storage/storage.js
Original file line number Diff line number Diff line change
Expand Up @@ -217,10 +217,13 @@ class VConsoleStorageTab extends VConsolePlugin {
if (!document.cookie || !navigator.cookieEnabled) {
return;
}

let hostname = window.location.hostname;
let list = this.getCookieList();
for (var i=0; i<list.length; i++) {
document.cookie = list[i].name + '=;expires=Thu, 01 Jan 1970 00:00:00 GMT';
let name=list[i].name;
document.cookie = `${name}=;expires=Thu, 01 Jan 1970 00:00:00 GMT`;
document.cookie = `${name}=;expires=Thu, 01 Jan 1970 00:00:00 GMT;path=/`;
document.cookie = `${name}=;expires=Thu, 01 Jan 1970 00:00:00 GMT;path=/;domain=.${hostname.split('.').slice(-2).join('.')}`;
}
this.renderStorage();
}
Expand Down

0 comments on commit c8addd4

Please sign in to comment.