From a29c52d16bdae8fdae32bd71369863d5a7047deb Mon Sep 17 00:00:00 2001 From: Alex Schroeder Date: Wed, 11 Aug 2021 00:58:14 +0200 Subject: [PATCH 1/1] Fix display of local file links MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit The code that shows an IRI for URLs if no display-string is provided used to display with double slashes when it happened upon a simple local filename link, like this: => /some/file.gmi Result: → ///some/file.gmi In order to fix this, we need to make sure that url-fullness remains nil. This commit makes sure that it is only set if the URL in question does in fact have a non-empty host (an empty host results in a host of "" is a true value, so we need an extra test using string-empty-p). This happens in both elpher-address-from-url and elpher-address-from-gemini-url. --- elpher.el | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/elpher.el b/elpher.el index a265a8f..1c19259 100644 --- a/elpher.el +++ b/elpher.el @@ -332,7 +332,6 @@ is not explicitly given." (unwind-protect (let ((url (url-generic-parse-url url-string))) (unless (and (not (url-fullness url)) (url-type url)) - (setf (url-fullness url) t) (unless (url-type url) (setf (url-type url) default-scheme)) (unless (url-host url) @@ -342,7 +341,8 @@ is not explicitly given." (if (cdr p) (concat "/" (mapconcat #'identity (cdr p) "/")) "")))) - (when (url-host url) + (when (not (string-empty-p (url-host url))) + (setf (url-fullness url) t) (setf (url-host url) (puny-encode-domain (url-host url)))) (when (or (equal "gopher" (url-type url)) (equal "gophers" (url-type url))) @@ -1489,11 +1489,11 @@ treatment that a separate function is warranted." (let ((address (url-generic-parse-url url)) (current-address (elpher-page-address elpher-current-page))) (unless (and (url-type address) (not (url-fullness address))) ;avoid mangling mailto: urls - (setf (url-fullness address) t) (if (url-host address) ;if there is an explicit host, filenames are absolute (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) (not (string-empty-p (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-filename address) -- 2.20.1