diff --git a/etc/init.lisp b/etc/init.lisp index 1ed6564..e840b0f 100644 --- a/etc/init.lisp +++ b/etc/init.lisp @@ -264,7 +264,7 @@ (define-key "I" #'print-post-id *thread-keymap*) -(define-key "s d" #'status-tree->text *thread-keymap*) +(define-key "s d" #'status-tree->text *thread-keymap*) (define-key "up" #'thread-go-up *thread-keymap*) diff --git a/src/gopher/parser.lisp b/src/gopher/parser.lisp index 4c2d35b..aa9d756 100644 --- a/src/gopher/parser.lisp +++ b/src/gopher/parser.lisp @@ -316,16 +316,25 @@ (defun parse-text-file (data) (parse 'text-file data)) +(defrule gopher-url-authority (or (and (+ (not #\:)) + #\: + (+ (not #\/)) + #\/) + (and (+ (not #\/)) + #\/)) + (:function (lambda (a) + (let* ((host-port a) + (host (coerce (first host-port) 'string)) + (port (if (third host-port) + (parse-integer (coerce (third host-port) 'string)) + 70))) + (list host port))))) + (defrule gopher-url (and (+ (not #\:)) "://" - (or (and (+ (not #\:)) - #\: - (+ (not #\/)) - #\/) - (and (+ (not #\/)) - #\/)) - (? (and (+ (not #\/)) - #\/)) + gopher-url-authority + (? (and (not #\/) + (& #\/))) (* (character-ranges (#\u0000 #\uffff)))) (:function (lambda (a) (let* ((host-port (third a)) @@ -335,9 +344,12 @@ 70)) (type-path (fourth a)) (type (if (car type-path) - (coerce (car type-path) 'string) + (string (car type-path)) +line-type-dir+)) (path (coerce (fifth a) 'string))) + (when (and (string-not-empty-p path) + (not (car type-path))) + (setf path (strcat "/" path))) (list host port path type))))) (defun parse-iri (iri)