diff --git a/src/page-file.rkt b/src/page-file.rkt index 1802568..a8a41a8 100644 --- a/src/page-file.rkt +++ b/src/page-file.rkt @@ -31,7 +31,8 @@ (rawImageUrl . "https://static.wikia.nocookie.net/examplefile") (userName . "blankie") (isPostedIn . #t) - (smallerArticleList . (#hasheq((titleText . "Test:Example article")))) + (smallerArticleList . (#hasheq((title . "Example_article") + (titleText . "Example article")))) (articleListIsSmaller . 0) (exists . #t) (imageDescription . #f)))) @@ -88,8 +89,8 @@ ,(if is-posted-in `(p "This file is used in " ,@(map (λ (article) - (define title (jp "/titleText" article)) - (define page-path (regexp-replace* #rx" " title "_")) + (define page-path (jp "/title" article)) + (define title (jp "/titleText" article page-path)) `(span ,(if (eq? (car smaller-article-list) article) "" ", ") (a (@ (href ,(format "/~a/wiki/~a" wikiname page-path))) ,title))) diff --git a/src/page-wiki.rkt b/src/page-wiki.rkt index 488886f..6499a86 100644 --- a/src/page-wiki.rkt +++ b/src/page-wiki.rkt @@ -52,7 +52,7 @@ (a (@ (data-test-wikilink) (href "https://test.fandom.com/wiki/Another_Page") (title "Another Page")) "Another Page")))) (figure (@ (class "thumb tnone")) - (a (@ (href "https://static.wikia.nocookie.net/nice-image.png") (class "image") (data-test-figure-a)) + (a (@ (href "https://static.wikia.nocookie.net/nice-image.png") (class "image")) (img (@ (src "data:image/gif;base64,R0lGODlhAQABAIABAAAAAP///yH5BAEAAAEALAAAAAABAAEAQAICTAEAOw%3D%3D") (data-src "https://static.wikia.nocookie.net/nice-image-thumbnail.png") (class "thumbimage lazyload")))) @@ -255,11 +255,6 @@ (λ (t a c) (and (eq? t 'a) (has-class? "image-thumbnail" a))) transformed)))) "/proxy?dest=https%3A%2F%2Fstatic.wikia.nocookie.net%2Fnice-image.png") - (check-equal? (get-attribute 'href (bits->attributes - ((query-selector - (λ (t a c) (member '(data-test-figure-a) a)) - transformed)))) - "/proxy?dest=https%3A%2F%2Fstatic.wikia.nocookie.net%2Fnice-image.png") ; check that noscript images are removed (check-equal? ((query-selector (λ (t a c) (eq? t 'noscript)) transformed)) #f)) diff --git a/src/url-utils.rkt b/src/url-utils.rkt index b70b245..10df089 100644 --- a/src/url-utils.rkt +++ b/src/url-utils.rkt @@ -22,7 +22,7 @@ (module+ test (require "typed-rackunit.rkt")) -(define px-wikiname "[a-zA-Z0-9-]{1,50}") +(define px-wikiname "[a-zA-Z0-9-]{3,50}") ;; https://url.spec.whatwg.org/#urlencoded-serializing