From 3fd0b0f89b396fbae4ba7960b2e5f4829ae7c933 Mon Sep 17 00:00:00 2001 From: blankie Date: Sun, 2 Oct 2022 09:59:19 +0700 Subject: [PATCH] Fix wikis with numbers in the name https://github.com/Wikia/app/blob/fe60579a53f16816d65dad1644363160a63206a6/extensions/wikia/CreateNewWiki/CreateWikiChecks.php#L112 Fixes https://lists.sr.ht/~cadence/breezewiki-discuss/%3C814ef2a8-2e91-dcaf-f0c1-805cc1478198%40riseup.net%3E --- src/dispatcher-tree.rkt | 8 ++++---- src/page-wiki.rkt | 2 +- src/url-utils.rkt | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/dispatcher-tree.rkt b/src/dispatcher-tree.rkt index 16f6c71..458262b 100644 --- a/src/dispatcher-tree.rkt +++ b/src/dispatcher-tree.rkt @@ -43,9 +43,9 @@ (pathprocedure:make "/" (hash-ref ds 'page-home)) (pathprocedure:make "/proxy" (hash-ref ds 'page-proxy)) (pathprocedure:make "/search" (hash-ref ds 'page-global-search)) - (filter:make #rx"^/[a-z-]+/wiki/Category:.+$" (lift:make (hash-ref ds 'page-category))) - (filter:make #rx"^/[a-z-]+/wiki/.+$" (lift:make (hash-ref ds 'page-wiki))) - (filter:make #rx"^/[a-z-]+/search$" (lift:make (hash-ref ds 'page-search))) - (filter:make #rx"^/[a-z-]+(/(wiki(/)?)?)?$" (lift:make (hash-ref ds 'redirect-wiki-home))) + (filter:make #rx"^/[a-zA-Z0-9-]{3,50}/wiki/Category:.+$" (lift:make (hash-ref ds 'page-category))) + (filter:make #rx"^/[a-zA-Z0-9-]{3,50}/wiki/.+$" (lift:make (hash-ref ds 'page-wiki))) + (filter:make #rx"^/[a-zA-Z0-9-]{3,50}/search$" (lift:make (hash-ref ds 'page-search))) + (filter:make #rx"^/[a-zA-Z0-9-]{3,50}(/(wiki(/)?)?)?$" (lift:make (hash-ref ds 'redirect-wiki-home))) (hash-ref ds 'static-dispatcher) (lift:make (hash-ref ds 'page-not-found))))))) diff --git a/src/page-wiki.rkt b/src/page-wiki.rkt index 2882ba5..b234301 100644 --- a/src/page-wiki.rkt +++ b/src/page-wiki.rkt @@ -143,7 +143,7 @@ (λ (href) ((compose1 (λ (href) (regexp-replace #rx"^(/wiki/.*)" href (format "/~a\\1" wikiname))) - (λ (href) (regexp-replace #rx"^https://([a-z-]+).fandom.com(/wiki/.*)" href "/\\1\\2"))) + (λ (href) (regexp-replace #rx"^https://([a-zA-Z0-9-]{3,50}).fandom.com(/wiki/.*)" href "/\\1\\2"))) href))) ; add noreferrer to a.image (curry u diff --git a/src/url-utils.rkt b/src/url-utils.rkt index f563b69..45b1f4b 100644 --- a/src/url-utils.rkt +++ b/src/url-utils.rkt @@ -57,7 +57,7 @@ (: is-fandom-url? (String -> Boolean)) (define (is-fandom-url? url) - (regexp-match? #rx"^https://static.wikia.nocookie.net/|^https://[a-z-]*.fandom.com/" url)) + (regexp-match? #rx"^https://static.wikia.nocookie.net/|^https://[a-zA-Z0-9-]{3,50}.fandom.com/" url)) (module+ test (check-true (is-fandom-url? "https://static.wikia.nocookie.net/wikiname/images/2/2f/SomeImage.jpg/revision/latest?cb=20110210094136")) (check-true (is-fandom-url? "https://test.fandom.com/wiki/Some_Page"))