diff --git a/lib/chibi/uri.scm b/lib/chibi/uri.scm index d5cfbd5d..e59a611b 100644 --- a/lib/chibi/uri.scm +++ b/lib/chibi/uri.scm @@ -170,7 +170,7 @@ (define (string->uri str . o) (apply string->path-uri #f str o)) -;;> Convert a URI object to a string. +;;> Convert a URI object to a string. Returns #f if the uri has no scheme. (define (uri->string uri . o) (define encode? (and (pair? o) (car o))) @@ -194,6 +194,14 @@ (if (pair? query) (uri-alist->query query) (or query "")) (if fragment "#" "") (if fragment (encode fragment) ""))))) +;;> Returns true iff the given URI string has a scheme. + +(define uri-has-scheme? + (let ((no-scheme (list 'no-scheme))) + (lambda (url) + (and url + (eq? no-scheme (uri-scheme (string->path-uri no-scheme url))))))) + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; query encoding and decoding diff --git a/lib/chibi/uri.sld b/lib/chibi/uri.sld index 0494e351..1a7310fe 100644 --- a/lib/chibi/uri.sld +++ b/lib/chibi/uri.sld @@ -1,6 +1,6 @@ (define-library (chibi uri) - (export uri? uri->string make-uri string->uri string->path-uri + (export uri? uri->string make-uri string->uri string->path-uri uri-has-scheme? uri-scheme uri-user uri-host uri-port uri-path uri-query uri-fragment uri-with-scheme uri-with-user uri-with-host uri-with-path uri-with-query uri-with-fragment