Function: rng-uri-resolve

rng-uri-resolve is a byte-compiled function defined in rng-uri.el.gz.

Signature

(rng-uri-resolve URI-REF BASE-URI)

Documentation

Resolve a possibly relative URI reference into absolute form.

URI-REF is the URI reference to be resolved. BASE-URI is the base URI to use for resolving it. The algorithm is specified by RFC 2396. If there is some problem with URI-REF or BASE-URI, then URI-REF will be returned.

Source Code

;; Defined in /usr/src/emacs/lisp/nxml/rng-uri.el.gz
(defun rng-uri-resolve (uri-ref base-uri)
  "Resolve a possibly relative URI reference into absolute form.
URI-REF is the URI reference to be resolved.
BASE-URI is the base URI to use for resolving it.
The algorithm is specified by RFC 2396.
If there is some problem with URI-REF or BASE-URI, then
URI-REF will be returned."
  (let* ((components (rng-uri-split uri-ref))
	 (scheme (nth 0 components))
	 (authority (nth 1 components))
	 (path (nth 2 components))
	 (query (nth 3 components))
	 (fragment-id (nth 4 components))
	 (base-components (rng-uri-split base-uri)))
    (if (or (not components)
	    scheme
	    (not base-components)
	    (not (nth 0 base-components)))
	uri-ref
      (setq scheme (nth 0 base-components))
      (when (not authority)
	(setq authority (nth 1 base-components))
	(if (and (equal path "") (not query))
	    ;; Handle same document reference by returning
	    ;; same URI (RFC 2396bis does this too).
	    (setq path (nth 2 base-components)
		  query (nth 3 base-components))
	  (setq path (rng-resolve-path path (nth 2 base-components)))))
      (rng-uri-join scheme
		    authority
		    path
		    query
		    fragment-id))))