Function: url-domain
url-domain is an autoloaded and byte-compiled function defined in
url-util.el.gz.
Signature
(url-domain URL)
Documentation
Return the domain of the host of the URL.
Return nil if this can't be determined.
For instance, this function will return "fsf.co.uk" if the host in URL is "www.fsf.co.uk".
Source Code
;; Defined in /usr/src/emacs/lisp/url/url-util.el.gz
;;;###autoload
(defun url-domain (url)
"Return the domain of the host of the URL.
Return nil if this can't be determined.
For instance, this function will return \"fsf.co.uk\" if the host in URL
is \"www.fsf.co.uk\"."
(let* ((host (puny-encode-domain (url-host url)))
(parts (nreverse (split-string host "\\.")))
(candidate (pop parts))
found)
;; IP addresses aren't domains.
(when (string-match "\\`[0-9.]+\\'" host)
(setq parts nil))
;; We assume that the top-level domain is never an appropriate
;; thing as "the domain", so we start at the next one (eg.
;; "fsf.org").
(while (and parts
(not (setq found
(url-domsuf-cookie-allowed-p
(setq candidate (concat (pop parts) "."
candidate))))))
)
(and found candidate)))