Proper handling of query-only gemini links.
authorplugd <plugd@thelambdalab.xyz>
Wed, 14 Feb 2024 09:49:24 +0000 (10:49 +0100)
committerplugd <plugd@thelambdalab.xyz>
Wed, 14 Feb 2024 09:49:24 +0000 (10:49 +0100)
elpher.el

index 608f09d..4a98cb3 100644 (file)
--- a/elpher.el
+++ b/elpher.el
@@ -1607,12 +1607,18 @@ treatment that a separate function is warranted."
           (if (string-empty-p (url-filename address))
               (setf (url-filename address) "/")) ;ensure empty filename is marked as absolute
         (setf (url-host address) (url-host current-address))
-        (setf (url-fullness address) (url-host address)) ; set fullness to t if host is set
-        (setf (url-portspec address) (url-portspec current-address)) ; (url-port) too slow!
-        (unless (string-prefix-p "/" (url-filename address)) ;deal with relative links
+        (setf (url-fullness address) (url-host address)) ;set fullness to t if host is set
+        (setf (url-portspec address) (url-portspec current-address)) ;(url-port) too slow!
+        (cond
+         ((string-prefix-p "/" (url-filename address))) ;do nothing for absolute case
+         ((string-prefix-p "?" (url-filename address)) ;handle query-only links
+          (setf (url-filename address)
+                (concat (url-filename current-address)
+                        (url-filename address))))
+         (t ;deal with relative links
           (setf (url-filename address)
                 (concat (file-name-directory (url-filename current-address))
-                        (url-filename address)))))
+                        (url-filename address))))))
       (when (url-host address)
         (setf (url-host address) (puny-encode-domain (url-host address))))
       (unless (url-type address)