From 4ddfca0f74d11f857426567e8dbbe7b4b09b2071 Mon Sep 17 00:00:00 2001 From: ManeraKai Date: Tue, 7 Mar 2023 18:42:06 +0300 Subject: [PATCH] Added support to subdomains for scribe https://github.com/libredirect/libredirect/issues/644 --- src/assets/javascripts/services.js | 10 ++++++++++ src/config.json | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/assets/javascripts/services.js b/src/assets/javascripts/services.js index bedc354..07f7a52 100644 --- a/src/assets/javascripts/services.js +++ b/src/assets/javascripts/services.js @@ -181,6 +181,16 @@ function redirect(url, type, initiator, forceRedirection) { } return `${randomInstance}${url.pathname}${url.search}` } + case "scribe": { + const regex = url.hostname.match(/^(link|cdn-images-\d+|.*)\.medium\.com/) + if (regex && regex.length > 1) { + const subdomain = regex[1] + if (subdomain != "link" || !subdomain.startsWith("cdn-images")) { + return `${randomInstance}/@${subdomain}${url.pathname}${url.search}` + } + } + return `${randomInstance}${url.pathname}${url.search}` + } case "simplyTranslate": { return `${randomInstance}/${url.search}` } diff --git a/src/config.json b/src/config.json index 3bd300a..7f2071b 100644 --- a/src/config.json +++ b/src/config.json @@ -236,7 +236,7 @@ } }, "targets": [ - "^https:\\/{2}(link\\.|cdn\\-images\\-\\d+\\.)?medium\\.com", + "^https:\\/{2}(.*\\.)?medium\\.com", "^https?:\\/{2}towardsdatascience\\.com(\\/|$)", "^https?:\\/{2}uxdesign\\.cc(\\/|$)", "^https?:\\/{2}uxplanet\\.org(\\/|$)",