~edwardloveall/scribe

Further improve proposed pattern for Redirector v2 APPLIED

Martin Puppe: 1
 Further improve proposed pattern for Redirector

 1 files changed, 2 insertions(+), 2 deletions(-)
Export patchset (mbox)
How do I use this?

Copy & paste the following snippet into your terminal to import this patchset into git:

curl -s https://lists.sr.ht/~edwardloveall/scribe/patches/25711/mbox | git am -3
Learn more about email & git

[PATCH v2] Further improve proposed pattern for Redirector Export this patch

This patch further improves the proposed pattern for the Redirector
extension. In contrast to the old pattern, …

* … it will redirect the URL https://medium.com.
* … it will *not* redirect URLs with top-level domains like mediumXcom.
  (This point is purely theoretical, but it makes the regular expression
  more correct and consistent.)
* … it will *not* redirect URLs like https://link.medium.com/AXEtCilplkb
  which Scribe currently cannot handle. These are shortened URLs that
  users get when they use the Twitter button on Medium to share a post.

In order to implement the last point (not matching link.medium.com), the
pattern uses negative lookbehind. This feature of regular expressions is
supported by all recent browsers for which Redirector is available
(Firefox, Chrome, Edge, Opera)[^1], including the current version of
Firefox ESR (Extended Stability Release).

[^1]: https://caniuse.com/js-regexp-lookbehind
---
 src/pages/home/index_page.cr | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/pages/home/index_page.cr b/src/pages/home/index_page.cr
index c930a6c..940e5b3 100644
--- a/src/pages/home/index_page.cr
+++ b/src/pages/home/index_page.cr
@@ -53,13 +53,13 @@ class Home::IndexPage < MainLayout
          end
          li do
            strong "Include pattern: "
            code "^https?://(?:.*\\.)*medium.com/(.*)$"
            code "^https?://(?:.*\\.)*(?<!link\\.)medium\\.com(/.*)?$"
          end
          li do
            strong "Redirect to: "
            code "https://"
            code app_domain
            code "/$1"
            code "$1"
          end
          li do
            strong "Pattern type: "
-- 
2.31.1
Thanks Martin. Merged and deployed.

Edward

On 15 Oct 2021, at 4:10, Martin Puppe wrote: