1
0
Fork 0

- fixed 'absolute-url-p'.

This commit is contained in:
cage 2024-11-24 16:55:11 +01:00
parent 93dd9b1c11
commit e070f89b05
2 changed files with 7 additions and 6 deletions

View File

@ -405,7 +405,8 @@
(null (iri:host iri))))) (null (iri:host iri)))))
(defun absolute-url-p (url) (defun absolute-url-p (url)
(not (relative-url-p url))) (and (not (relative-url-p url))
(iri:iri-parse url :null-on-error t)))
(defun absolute-url-scheme-p (url expected-scheme) (defun absolute-url-scheme-p (url expected-scheme)
(when-let ((parsed-iri (iri:iri-parse url :null-on-error t))) (when-let ((parsed-iri (iri:iri-parse url :null-on-error t)))

View File

@ -749,15 +749,15 @@ printed in the box column by column; in the example above the results are:
constants:+internal-scheme-local-posts+))) constants:+internal-scheme-local-posts+)))
"Collect all hyperlinks in a text marked from a list of valid `schemes'" "Collect all hyperlinks in a text marked from a list of valid `schemes'"
(flet ((build-re-scheme () (flet ((build-re-scheme ()
(let ((res "")) (let ((res "^"))
(loop for (scheme . rest) on schemes do (loop for (scheme . rest) on schemes do
(if rest (if rest
(setf res (strcat res "(" scheme ")|")) (setf res (strcat res "(" scheme ")|"))
(setf res (strcat res "(" scheme ")://")))) (setf res (strcat res "(" scheme ")://"))))
(strcat "(" res ")")))) (strcat "(" res ")"))))
(a:when-let* ((all-uris (lines->uri text)) (a:when-let* ((all-uris (lines->uri text))
(re (strcat (build-re-scheme) "\\P{White_Space}+")) (re (strcat (build-re-scheme) "\\P{White_Space}+"))
(scanner (cl-ppcre:create-scanner re))) (scanner (cl-ppcre:create-scanner re)))
(let ((results '())) (let ((results '()))
(loop for uri in all-uris when (cl-ppcre:scan scanner uri) do (loop for uri in all-uris when (cl-ppcre:scan scanner uri) do
(pushnew uri results :test #'string=)) (pushnew uri results :test #'string=))