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 `\\\\`
This commit is contained in:
Edward Loveall 2022-07-19 16:13:02 -04:00
parent 449ece843a
commit 4097aa20df
No known key found for this signature in database
GPG Key ID: A7606DFEC2BA731F
3 changed files with 33 additions and 28 deletions

View File

@ -1,3 +1,7 @@
2022-07-19
* Fix downloadable config file for Redirector extension
2022-07-17 2022-07-17
* Fix source code link * Fix source code link

View File

@ -15,34 +15,35 @@ class RedirectionConfig::Index < Lucky::Action
end end
private def config_json private def config_json
double_escaped_pattern = "^https?://(?:.*\\\\.)*(?<!(link\\\\.|cdn\\\\-images\\\\-\\\\d+\\\\.))medium\\\\.com(/.*)?$"
<<-JSON <<-JSON
{ {
"createdBy": "Redirector v3.5.3", "createdBy": "Redirector v3.5.3",
"createdAt": "2022-07-17T00:00:00.000Z", "createdAt": "2022-07-17T00:00:00.000Z",
"redirects": [ "redirects": [
{ {
"description": "Medium -> Scribe", "description": "Medium -> Scribe",
"exampleUrl": "https://medium.com/@user/post-123456abcdef", "exampleUrl": "https://medium.com/@user/post-123456abcdef",
"exampleResult": "https://#{app_domain}/@user/post-123456abcdef", "exampleResult": "https://#{app_domain}/@user/post-123456abcdef",
"error": null, "error": null,
"includePattern": "^https?://(?:.*\\.)*(?<!(link\\.|cdn\\-images\\-\\d+\\.))medium\\.com(/.*)?$", "includePattern": "#{double_escaped_pattern}",
"excludePattern": "", "excludePattern": "",
"patternDesc": "", "patternDesc": "",
"redirectUrl": "https://#{app_domain}$2", "redirectUrl": "https://#{app_domain}$2",
"patternType": "R", "patternType": "R",
"processMatches": "noProcessing", "processMatches": "noProcessing",
"disabled": false, "disabled": false,
"grouped": false, "grouped": false,
"appliesTo": [ "appliesTo": [
"main_frame", "main_frame",
"sub_frame", "sub_frame",
"xmlhttprequest", "xmlhttprequest",
"history", "history",
"other" "other"
] ]
} }
] ]
} }
JSON JSON
end end

View File

@ -1,3 +1,3 @@
module Scribe module Scribe
VERSION = "2022-07-17" VERSION = "2022-07-19"
end end