Function: url-recreate-url

url-recreate-url is an autoloaded and byte-compiled function defined in url-parse.el.gz.

Signature

(url-recreate-url URLOBJ)

Documentation

Recreate a URL string from the parsed URLOBJ.

Source Code

;; Defined in /usr/src/emacs/lisp/url/url-parse.el.gz
;;;###autoload
(defun url-recreate-url (urlobj)
  "Recreate a URL string from the parsed URLOBJ."
  (let* ((type (url-type urlobj))
	 (user (url-user urlobj))
	 (pass (url-password urlobj))
	 (host (url-host urlobj))
	 ;; RFC 3986: "omit the port component and its : delimiter if
	 ;; port is empty or if its value would be the same as that of
	 ;; the scheme's default."
	 (port (url-port-if-non-default urlobj))
         ;; For Windows/DOS-like paths, `url-generic-parse-url' strips
         ;; the leading /, so we need to add it back (bug#76982)
	 (file (if (and (string= "file" type)
                        (url-filename urlobj)
                        (string-match "^[A-Za-z]:[/\\]" (url-filename urlobj)))
                   (concat "/" (url-filename urlobj))
                 (url-filename urlobj)))
	 (frag (url-target urlobj)))
    (concat (if type (concat type ":"))
	    (if (url-fullness urlobj) "//")
	    (if (or user pass)
		(concat user
			(if pass (concat ":" pass))
			"@"))
	    host
	    (if port (format ":%d" (url-port urlobj)))
	    (or file "/")
	    (if frag (concat "#" frag)))))