Skip to content
This repository was archived by the owner on Nov 22, 2021. It is now read-only.

Commit d585e2a

Browse files
author
Ke, Mingze
committed
Using location.origin as the localStorage key
1 parent 8b17f6c commit d585e2a

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

storage.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ BlocklyStorage.backupBlocks_ = function (workspace) {
4343
if ('localStorage' in window) {
4444
var xml = Blockly.Xml.workspaceToDom(workspace);
4545
// Gets the current URL, not including the hash.
46-
var url = window.location.href.split('#')[0];
46+
var url = window.location.origin;
4747
window.localStorage.setItem(url, Blockly.Xml.domToText(xml));
4848
}
4949
};
@@ -67,7 +67,7 @@ BlocklyStorage.backupOnUnload = function (opt_workspace) {
6767
* @param {Blockly.WorkspaceSvg} opt_workspace Workspace.
6868
*/
6969
BlocklyStorage.restoreBlocks = function (opt_workspace) {
70-
var url = window.location.href.split('#')[0];
70+
var url = window.location.origin;
7171
if ('localStorage' in window && window.localStorage[url]) {
7272
var workspace = opt_workspace || Blockly.getMainWorkspace();
7373
var xml = Blockly.Xml.textToDom(window.localStorage[url]);

0 commit comments

Comments
 (0)