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 `\\\\`
main 2022-07-19
Edward Loveall 2022-07-19 16:13:02 -04:00
rodzic 449ece843a
commit 4097aa20df
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: A7606DFEC2BA731F
3 zmienionych plików z 33 dodań i 28 usunięć

Wyświetl plik

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

Wyświetl plik

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

Wyświetl plik

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