Compare commits

...

3 commits

3 changed files with 10 additions and 6 deletions

View file

@ -31,8 +31,7 @@
(rawImageUrl . "https://static.wikia.nocookie.net/examplefile")
(userName . "blankie")
(isPostedIn . #t)
(smallerArticleList . (#hasheq((title . "Example_article")
(titleText . "Example article"))))
(smallerArticleList . (#hasheq((titleText . "Test:Example article"))))
(articleListIsSmaller . 0)
(exists . #t)
(imageDescription . #f))))
@ -89,8 +88,8 @@
,(if is-posted-in
`(p "This file is used in "
,@(map (λ (article)
(define page-path (jp "/title" article))
(define title (jp "/titleText" article page-path))
(define title (jp "/titleText" article))
(define page-path (regexp-replace* #rx" " title "_"))
`(span ,(if (eq? (car smaller-article-list) article) "" ", ")
(a (@ (href ,(format "/~a/wiki/~a" wikiname page-path)))
,title)))

View file

@ -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"))
(a (@ (href "https://static.wikia.nocookie.net/nice-image.png") (class "image") (data-test-figure-a))
(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,6 +255,11 @@
(λ (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))

View file

@ -22,7 +22,7 @@
(module+ test
(require "typed-rackunit.rkt"))
(define px-wikiname "[a-zA-Z0-9-]{3,50}")
(define px-wikiname "[a-zA-Z0-9-]{1,50}")
;; https://url.spec.whatwg.org/#urlencoded-serializing