mirror of
https://github.com/ashinn/chibi-scheme.git
synced 2025-05-21 14:49:18 +02:00
Adding uri-has-scheme? utility.
This commit is contained in:
parent
24d22644d0
commit
5246763c8b
2 changed files with 10 additions and 2 deletions
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Add table
Reference in a new issue