Skip to content

Commit

Permalink
Get basic support for URI encoded code
Browse files Browse the repository at this point in the history
  • Loading branch information
williamd1k0 committed Nov 2, 2024
1 parent 7030fd1 commit 6c0a347
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion web/src/js/scriptimport.js.j2
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@

function get_external_script_source() {
if (location.search.match(/code=(.+)/)) {
return "code";
}
if (location.search.match(/rentry=(.+)&?/)) {
return "rentry";
}
Expand All @@ -20,6 +23,9 @@ function fetch_external_script() {
let source = get_external_script_source();
if (source === undefined) return;
switch (source) {
case "code":
EDITOR.setValue(decodeURIComponent(location.search.match(/code=(.+)/)[1]));
break;
case "lz":
EDITOR.setValue(LZString.decompressFromEncodedURIComponent(location.search.substring(1)));
break;
Expand Down Expand Up @@ -50,4 +56,4 @@ function fetch_external_script() {
});
break;
}
}
}

0 comments on commit 6c0a347

Please sign in to comment.