Skip to content

Commit 241a9d2

Browse files
committed
Add support for local loading
1 parent 27e61c1 commit 241a9d2

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

dev/src/RegExr.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,10 @@ export default class RegExr extends EventDispatcher {
6060
this._savedHash = null;
6161

6262
let params = Utils.getUrlParams();
63+
if (Utils.isLocal && params.id) {
64+
Server.load(params.id).then((o) => this.state = o);
65+
params = {};
66+
}
6367
if (params.engine) { this.flavor.value = params.engine; }
6468
if (params.expression) { this.expression.value = params.expression; }
6569
if (params.text) { this.text.value = params.text; }

dev/src/utils/Utils.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -150,16 +150,18 @@ Utils.getHashCode = function(s) {
150150
};
151151

152152
Utils.getPatternURL = function(pattern) {
153-
let url = window.location.origin+"/", id=pattern&&pattern.id||"";
154-
return url+id;
153+
let a = Utils.isLocal ? "?id=" : "/";
154+
let url = window.location.origin, id=pattern&&pattern.id||"";
155+
return url+a+id;
155156
}
156157

157158
Utils.isLocal = (window.location.hostname === "localhost");
158159

159160
Utils.getPatternURLStr = function(pattern) {
160161
if (!pattern || !pattern.id) { return null; }
161-
let url = window.location.host+"/", id=pattern.id;
162-
return url+id;
162+
let a = Utils.isLocal ? "?id=" : "/";
163+
let url = window.location.host, id=pattern.id;
164+
return url+a+id;
163165
}
164166

165167
Utils.getForkName = function(name) {

0 commit comments

Comments
 (0)