Add test for lm-website

* lisp/emacs-lisp/lisp-mnt.el (lm-website): Use rx.
* test/lisp/emacs-lisp/lisp-mnt-tests.el
(lm--tests-lm-website): New test.
This commit is contained in:
Stefan Kangas 2021-09-26 14:13:03 +02:00
parent 6e1de14e51
commit a0d5de4fb9
2 changed files with 11 additions and 3 deletions

View file

@ -501,9 +501,9 @@ absent, return nil."
(defun lm-website (&optional file)
"Return the website in file FILE, or current buffer if FILE is nil."
(let ((page (lm-with-file file
(lm-header "\\(?:x-\\)?\\(?:url\\|homepage\\)"))))
(if (and page (string-match "^<.+>$" page))
(substring page 1 -1)
(lm-header (rx (? "x-") (or "url" "homepage"))))))
(if (and page (string-match (rx bol "<" (+ nonl) ">" eol) page))
(substring page 1 -1)
page)))
(defalias 'lm-homepage 'lm-website) ; for backwards-compatibility