mirror of https://codeberg.org/cage/tinmop/
- added a new parser just for gopher address; they are not IRI as the
selector part can contains arbitrary characters even that ones that are not allowed in IRI's path component.
This commit is contained in:
parent
9b6e6a9f15
commit
60f33d81a9
|
@ -316,11 +316,32 @@
|
|||
(defun parse-text-file (data)
|
||||
(parse 'text-file data))
|
||||
|
||||
(defrule gopher-url (and (+ (not #\:))
|
||||
"://"
|
||||
(or (and (+ (not #\:))
|
||||
#\:
|
||||
(+ (not #\/))
|
||||
#\/)
|
||||
(and (+ (not #\/))
|
||||
#\/))
|
||||
(and (+ (not #\/))
|
||||
#\/)
|
||||
(* (character-ranges (#\u0000 #\uffff))))
|
||||
(:function (lambda (a)
|
||||
(let* ((host-port (third a))
|
||||
(host (coerce (first host-port) 'string))
|
||||
(port (if (third host-port)
|
||||
(parse-integer (coerce (third host-port) 'string))
|
||||
70))
|
||||
(type-path (fourth a))
|
||||
(type (coerce (car type-path) 'string))
|
||||
(path (coerce (fifth a) 'string)))
|
||||
(list host port path type)))))
|
||||
|
||||
(defun parse-iri (iri)
|
||||
(let* ((parsed (iri:iri-parse iri))
|
||||
(host (uri:host parsed))
|
||||
(port (or (uri:port parsed) 70))
|
||||
(path (uri:path parsed))
|
||||
(type (second (fs:split-path-elements path)))
|
||||
(selector (subseq path (+ 2 (length type)))))
|
||||
(let* ((parsed (parse 'gopher-url iri))
|
||||
(host (first parsed))
|
||||
(port (second parsed))
|
||||
(selector (third parsed))
|
||||
(type (fourth parsed)))
|
||||
(values host port type selector)))
|
||||
|
|
Loading…
Reference in New Issue