(register-url-parser string function) -> #f
Registers a function to generate URL objects from the five fundamental portions of a URL: scheme, authority, path, query and fragment, which will then be used by string->url when parsing a URL string. Register-url-parser adds the new parser to *url-parsers*
This is used by http-url, for example, to register a sophisticated parser capable of parsing HTTP URLs.
The following is a complete example that shows how to register a URL-parser to handle "mailto:" URLs.
(define-class mailto-url <object> (make-mailto-url user host) mailto-url? (user mailto-url-user) (host mailto-url-host)) (define *mailto-path-regex* (make-regex "(.*)@(.*)")) (define (parse-mailto-url scheme auth path query frag) (define result (match-regex *mailto-path-regex* path)) (if result (make-mailto-url (car result) (cadr result)) (make-mailto-url path))) (register-url-parser "mailto" parse-mailto-url) (define (url-scheme (<mailto-url> url)) "mailto") (define (url-auth (<mailto-url> url)) #f) (define (url-path (<mailto-url> url)) (if (mailto-url-host url) (string-append (mailto-url-user url) "@" (mailto-url-host url)) (mailto-url-user url))) (define (url-query (<mailto-url> url)) #f) (define (url-frag (<mailto-url> url)) #f)