summaryrefslogtreecommitdiff
path: root/module
diff options
context:
space:
mode:
authorAndy Wingo <wingo@pobox.com>2011-12-06 11:47:41 +0100
committerAndy Wingo <wingo@pobox.com>2011-12-06 11:47:41 +0100
commit679eea4f0ef7720e0ed3c9ba3fddedf35d1501d6 (patch)
tree46eb9e23077dbf68e23ce4b766f228d467cde091 /module
parentfe0c202c0ea4ec1ab502b7e26fa70c9e734e8f6c (diff)
allow URIs of the form file:///etc/hosts
* module/web/uri.scm (parse-authority): Allow empty authorities, so that we accept URIs of the form, file:///etc/hosts. * test-suite/tests/web-uri.test ("string->uri"): Add tests.
Diffstat (limited to 'module')
-rw-r--r--module/web/uri.scm20
1 files changed, 12 insertions, 8 deletions
diff --git a/module/web/uri.scm b/module/web/uri.scm
index 6f9377c19..67ecbaeb2 100644
--- a/module/web/uri.scm
+++ b/module/web/uri.scm
@@ -125,14 +125,18 @@ consistency checks to make sure that the constructed URI is valid."
userinfo-pat host-pat port-pat)))
(define (parse-authority authority fail)
- (let ((m (regexp-exec authority-regexp authority)))
- (if (and m (valid-host? (match:substring m 3)))
- (values (match:substring m 2)
- (match:substring m 3)
- (let ((port (match:substring m 5)))
- (and port (not (string-null? port))
- (string->number port))))
- (fail))))
+ (if (equal? authority "//")
+ ;; Allow empty authorities: file:///etc/hosts is a synonym of
+ ;; file:/etc/hosts.
+ (values #f #f #f)
+ (let ((m (regexp-exec authority-regexp authority)))
+ (if (and m (valid-host? (match:substring m 3)))
+ (values (match:substring m 2)
+ (match:substring m 3)
+ (let ((port (match:substring m 5)))
+ (and port (not (string-null? port))
+ (string->number port))))
+ (fail)))))
;;; RFC 3986, #3.