Fix error with URL-parsing

Query parameters (post-?) were previously ignored.
This commit is contained in:
Jaidyn Ann 2024-05-29 21:18:34 -05:00
parent 28f40c5f6e
commit d9bead00b4

View File

@ -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 wouldnt 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)))