diff --git a/src/mirror-img.lisp b/src/mirror-img.lisp index 52b7544..525d1bf 100644 --- a/src/mirror-img.lisp +++ b/src/mirror-img.lisp @@ -139,7 +139,7 @@ already set)." (defun http-fetch (url path) "Download a URL to a path; if successful, returns the pathname. Otherwise, NIL." (handler-case - (and (dexador:fetch (url-encode-uri (quri:uri url)) path) + (and (dexador:fetch (url-encode-uri url) path) (pathname path)) (cl-user::file-exists () path) @@ -154,7 +154,7 @@ already set)." (quri:uri-scheme uri) (quri:uri-host uri) (uri-explicit-port uri) - (url-encode-path (quri:uri-path uri))))) + (url-encode-path (uri-path+query uri))))) ;; string → string (defun url-encode-path (path) @@ -178,3 +178,8 @@ That is, 443 is implied by HTTPS, so nil is returned; but 998 wouldn’t be impl (and (equal scheme "http") (eq port 80))) port))) + +;; quri-uri → string +(defun uri-path+query (uri) + "Return everything in a URI after the TLD — that is, both the path _and_ the query." + (format nil "~A~@[?~A~]" (quri:uri-path uri) (quri:uri-query uri)))