Fixed bug in non-gopher URL construction. v1.2.4
authorTim Vaughan <tgvaughan@gmail.com>
Wed, 19 Jun 2019 20:16:19 +0000 (22:16 +0200)
committerTim Vaughan <tgvaughan@gmail.com>
Wed, 19 Jun 2019 20:16:19 +0000 (22:16 +0200)
elpher.el

index 210824a..d1d795c 100644 (file)
--- a/elpher.el
+++ b/elpher.el
@@ -4,7 +4,7 @@
 
 ;; Author: Tim Vaughan <tgvaughan@gmail.com>
 ;; Created: 11 April 2019
-;; Version: 1.2.3
+;; Version: 1.2.4
 ;; Keywords: comm gopher
 ;; Homepage: https://github.com/tgvaughan/elpher
 ;; Package-Requires: ((emacs "25"))
@@ -57,7 +57,7 @@
 ;;; Global constants
 ;;
 
-(defconst elpher-version "1.2.3"
+(defconst elpher-version "1.2.4"
   "Current version of elpher.")
 
 (defconst elpher-margin-width 6
@@ -1013,14 +1013,20 @@ host, selector and port."
 
 (defun elpher-get-address-url (address)
   "Get URL representation of ADDRESS."
-  (concat "gopher://"
-          (elpher-address-host address)
-          (let ((port (elpher-address-port address)))
-            (if (equal port 70)
-                ""
-              (format ":%d" port)))
-          "/" (string (elpher-address-type address))
-          (elpher-address-selector address)))
+  (let ((type (elpher-address-type address))
+        (selector (elpher-address-selector address))
+        (host (elpher-address-host address))
+        (port (elpher-address-port address)))
+    (if (and (equal type ?h)
+             (string-prefix-p "URL:" selector))
+        (elt (split-string selector "URL:") 1)
+      (concat "gopher://"
+              host
+              (if (equal port 70)
+                  ""
+                (format ":%d" port))
+              "/" (string type)
+              selector))))
 
 (defun elpher-copy-node-url (node)
   "Copy URL representation of address of NODE to `kill-ring'."