- (let ((url (url-generic-parse-url url-string)))
- (if (and (url-type url)
- (url-host url))
- (let ((is-gopher (or (equal "gopher" (url-type url))
- (equal "gophers" (url-type url)))))
- (setf (url-filename url)
- (url-unhex-string (url-filename url)))
- (when (string-empty-p (url-filename url))
- (if is-gopher
- (setf (url-filename url) "1")))
- (unless (> (url-port url) 0)
- (if is-gopher
- (setf (url-port url) 70)))
- url)
- (error "Malformed URL" url))))
-
-(defun elpher-make-gopher-address (type selector host port)
+ (let ((data (match-data))) ; Prevent parsing clobbering match data
+ (unwind-protect
+ (let ((url (url-generic-parse-url url-string)))
+ (if (and (url-type url)
+ (url-host url))
+ (let ((is-gopher (or (equal "gopher" (url-type url))
+ (equal "gophers" (url-type url)))))
+ (setf (url-filename url)
+ (url-unhex-string (url-filename url)))
+ (when (string-empty-p (url-filename url))
+ (if is-gopher
+ (setf (url-filename url) "1")))
+ (unless (> (url-port url) 0)
+ (if is-gopher
+ (setf (url-port url) 70)))
+ url)
+ (error "Malformed URL" url)))
+ (set-match-data data))))
+
+(defun elpher-make-gopher-address (type selector host port &optional tls)