From 767eaac622114cbfbe6adbb9278e4a127fc3b805 Mon Sep 17 00:00:00 2001 From: Omer Abdulaziz Date: Thu, 12 Sep 2024 05:27:44 +0300 Subject: [PATCH] Embed selected rule in the url when sharing. (#65) * Embed selected rule in the url when sharing. * fix: check for undefined --- static/scripts/shareButton.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/static/scripts/shareButton.ts b/static/scripts/shareButton.ts index dee8de1..c7d2539 100644 --- a/static/scripts/shareButton.ts +++ b/static/scripts/shareButton.ts @@ -45,6 +45,9 @@ function tryLoadFromShareLink(codeMirror) { "textarea.editor-input-text", )!; inputEditor.value = decoded["input"]; + if (decoded["selectedRule"]) { + localStorage.setItem("last-selected-rule", decoded["selectedRule"]); + } } } @@ -54,6 +57,7 @@ function shareData(codeMirror) { input: document.querySelector( "textarea.editor-input-text", )!.value, + selectedRule: localStorage.getItem("last-selected-rule") || "", }; }