Match style URLs better in style archive server

This commit is contained in:
Cadence Ember 2023-02-08 19:44:32 +13:00
parent 7f85ce776b
commit 0ba20c9e38
Signed by: cadence
GPG Key ID: BC1C2C61CF521B17
2 changed files with 3 additions and 3 deletions

View File

@ -1,3 +1,3 @@
#lang info
(define build-deps '("rackunit-lib" "web-server-lib" "http-easy-lib" "html-parsing" "html-writing" "json-pointer" "ini-lib" "memo" "net-cookies-lib"))
(define build-deps '("rackunit-lib" "web-server-lib" "http-easy-lib" "html-parsing" "html-writing" "json-pointer" "typed-ini-lib" "memo" "net-cookies-lib"))

View File

@ -41,14 +41,14 @@
[(string-prefix? url "http://") (regexp-replace #rx"http:" url "https:")]
[(string-prefix? url "//") (string-append "https:" url)]
[(string-prefix? url "/") (format "https://~a.fandom.com~a" wikiname url)]
[else (raise-user-error "While calling replace-style-for-images, this URL had an unknown format and couldn't be saved:" url)])])
[else (error 'replace-style-for-images "unknown URL format: ~a" url)])])
(define p (image-url->values norm-url))
;; (printf "hashed: ~a~n -> ~a~n #-> ~a~n" url (car p) (cdr p))
(format "/archive/~a/images/~a" wikiname (cdr p))))))
(define (replace-style-for-images wikiname path)
(define content (file->string path))
(regexp-replace* #rx"url\\(([^)]*)\\)" content (replacer wikiname)))
(regexp-replace* #rx"url\\(\"?'?([^)]*)'?\"?\\)" content (replacer wikiname)))
(define (handle-style wikiname dest)
(when (config-true? 'debug)