From 4097aa20df0467fb402d0c7a1e903f63dcce00c1 Mon Sep 17 00:00:00 2001 From: Edward Loveall Date: Tue, 19 Jul 2022 16:13:02 -0400 Subject: [PATCH] Fix Redirector config escaped strings When printing out the configuration JSON, the Redirector extension expects regex escapes to be escaped, themselves. So `\` becomes `\\`. However, Crystal treats these as escaped character also, and each `\` must additionally be escaped, so a single slash becomes `\\\\` --- CHANGELOG | 4 ++ src/actions/redirection_config/index.cr | 55 +++++++++++++------------ src/version.cr | 2 +- 3 files changed, 33 insertions(+), 28 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index dfab3ea..4362880 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,7 @@ +2022-07-19 + +* Fix downloadable config file for Redirector extension + 2022-07-17 * Fix source code link diff --git a/src/actions/redirection_config/index.cr b/src/actions/redirection_config/index.cr index fa7af09..948e960 100644 --- a/src/actions/redirection_config/index.cr +++ b/src/actions/redirection_config/index.cr @@ -15,34 +15,35 @@ class RedirectionConfig::Index < Lucky::Action end private def config_json + double_escaped_pattern = "^https?://(?:.*\\\\.)*(? Scribe", - "exampleUrl": "https://medium.com/@user/post-123456abcdef", - "exampleResult": "https://#{app_domain}/@user/post-123456abcdef", - "error": null, - "includePattern": "^https?://(?:.*\\.)*(? Scribe", + "exampleUrl": "https://medium.com/@user/post-123456abcdef", + "exampleResult": "https://#{app_domain}/@user/post-123456abcdef", + "error": null, + "includePattern": "#{double_escaped_pattern}", + "excludePattern": "", + "patternDesc": "", + "redirectUrl": "https://#{app_domain}$2", + "patternType": "R", + "processMatches": "noProcessing", + "disabled": false, + "grouped": false, + "appliesTo": [ + "main_frame", + "sub_frame", + "xmlhttprequest", + "history", + "other" + ] + } + ] + } JSON end diff --git a/src/version.cr b/src/version.cr index a78241d..0163f61 100644 --- a/src/version.cr +++ b/src/version.cr @@ -1,3 +1,3 @@ module Scribe - VERSION = "2022-07-17" + VERSION = "2022-07-19" end