forked from cadence/breezewiki
simple tests
This commit is contained in:
parent
bc07a37bf7
commit
ba806d0633
1 changed files with 13 additions and 3 deletions
|
@ -33,13 +33,22 @@
|
||||||
(easy:response-headers-ref dest-res 'content-type))
|
(easy:response-headers-ref dest-res 'content-type))
|
||||||
|
|
||||||
(define (get-media-html url content-type)
|
(define (get-media-html url content-type)
|
||||||
|
(define proxied-url (if (config-true? 'strict_proxy) (u-proxy-url url) url))
|
||||||
(cond
|
(cond
|
||||||
[(eq? content-type #f) `""]
|
[(eq? content-type #f) `""]
|
||||||
[(regexp-match? #rx"(?i:^image/)" content-type) `(img (@ (src ,url)))]
|
[(regexp-match? #rx"(?i:^image/)" content-type) `(img (@ (src ,proxied-url)))]
|
||||||
[(regexp-match? #rx"(?i:^audio/|^application/ogg(;|$))" content-type)
|
[(regexp-match? #rx"(?i:^audio/|^application/ogg(;|$))" content-type)
|
||||||
`(audio (@ (src ,url) (controls)))]
|
`(audio (@ (src ,proxied-url) (controls)))]
|
||||||
[(regexp-match? #rx"(?i:^video/)" content-type) `(video (@ (src ,url) (controls)))]
|
[(regexp-match? #rx"(?i:^video/)" content-type) `(video (@ (src ,proxied-url) (controls)))]
|
||||||
[else `""]))
|
[else `""]))
|
||||||
|
(module+ test
|
||||||
|
(require rackunit)
|
||||||
|
(check-equal? (get-media-html "https://static.wikia.nocookie.net/a" "image/jpeg") (img (@ (src "/proxy?dest=https%3A%2F%2Fstatic.wikia.nocookie.net%2Fa"))))
|
||||||
|
(check-equal? (get-media-html "https://static.wikia.nocookie.net/b" "audio/mp3") (audio (@ (src "/proxy?dest=https%3A%2F%2Fstatic.wikia.nocookie.net%2Fb"))))
|
||||||
|
(check-equal? (get-media-html "https://static.wikia.nocookie.net/c" "application/ogg") (audio (@ (src "/proxy?dest=https%3A%2F%2Fstatic.wikia.nocookie.net%2Fc"))))
|
||||||
|
(check-equal? (get-media-html "https://static.wikia.nocookie.net/d" "video/mp4") (video (@ (src "/proxy?dest=https%3A%2F%2Fstatic.wikia.nocookie.net%2Fd"))))
|
||||||
|
(check-equal? (get-media-html "https://example.com" "who knows") "")
|
||||||
|
(check-equal? (get-media-html #f "who knows") ""))
|
||||||
|
|
||||||
(define (generate-results-page #:source-url source-url
|
(define (generate-results-page #:source-url source-url
|
||||||
#:wikiname wikiname
|
#:wikiname wikiname
|
||||||
|
@ -125,6 +134,7 @@
|
||||||
; convert to string with error checking, error will be raised if xexp is invalid
|
; convert to string with error checking, error will be raised if xexp is invalid
|
||||||
(xexp->html body))
|
(xexp->html body))
|
||||||
(response/output #:code 200
|
(response/output #:code 200
|
||||||
|
#:headers (list referrer-policy)
|
||||||
(λ (out) (write-html body out)))))))
|
(λ (out) (write-html body out)))))))
|
||||||
;(module+ test
|
;(module+ test
|
||||||
; (check-not-false ((query-selector (attribute-selector 'href "/test/wiki/Ankle_Monitor")
|
; (check-not-false ((query-selector (attribute-selector 'href "/test/wiki/Ankle_Monitor")
|
||||||
|
|
Loading…
Reference in a new issue