X-Git-Url: https://thelambdalab.xyz/gitweb/index.cgi?p=elpher.git;a=blobdiff_plain;f=elpher.el;h=1ea9e71b692b3ec664e69495835958e3586727dd;hp=7605bdf43f6ff7660c6e399a88f4a42c8d2e6c56;hb=b4fc468a644bdcbfcc371311c9984deb623bafff;hpb=e643d174d3244b97b14755f8a4ab48a5dfeaf693 diff --git a/elpher.el b/elpher.el index 7605bdf..1ea9e71 100644 --- a/elpher.el +++ b/elpher.el @@ -307,9 +307,25 @@ requiring gopher-over-TLS." (defun elpher-address-to-url (address) "Get string representation of ADDRESS, or nil if ADDRESS is special." - (if (not (elpher-address-special-p address)) - (url-encode-url (url-recreate-url address)) - nil)) + (if (elpher-address-special-p address) + nil + (let* ((port (url-port address)) + (address-to-convert + (if (= port 0) + address + (let ((address-copy (seq-copy address)) + (protocol (url-type address))) + (if (or (and (equal protocol "gopher") + (= port 70)) + (and (equal protocol "gemini") + (= port 1965)) + (and (equal protocol "http") + (= port 80)) + (and (equal protocol "finger") + (= port 79))) + (setf (url-port address-copy) 0)) + address-copy)))) + (url-encode-url (url-recreate-url address-to-convert))))) (defun elpher-address-type (address) "Retrieve type of ADDRESS object. @@ -1522,11 +1538,12 @@ If ADDRESS is already bookmarked, update the label only." "Go to a particular gopher site HOST-OR-URL. When run interactively HOST-OR-URL is read from the minibuffer." (interactive "sGopher or Gemini URL: ") - (let ((page (elpher-make-page host-or-url - (elpher-address-from-url host-or-url)))) + (let* ((cleaned-host-or-url (string-trim host-or-url)) + (address (elpher-address-from-url cleaned-host-or-url)) + (page (elpher-make-page cleaned-host-or-url address))) (switch-to-buffer "*elpher*") (elpher-visit-page page) - '())) + nil)) (defun elpher-go-current () "Go to a particular site read from the minibuffer, initialized with the current URL."