From a1e22d42d40cd236620148c5bae85f12aa67f1f9 Mon Sep 17 00:00:00 2001 From: Alex Shinn Date: Sun, 18 Aug 2013 17:09:39 +0900 Subject: [PATCH] Fixing bug in uri path parsing. --- lib/chibi/uri.scm | 10 +++++----- tests/uri-tests.scm | 9 +++++++++ 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/lib/chibi/uri.scm b/lib/chibi/uri.scm index 3c274474..9141c453 100644 --- a/lib/chibi/uri.scm +++ b/lib/chibi/uri.scm @@ -94,11 +94,11 @@ (end (string-cursor-end str)) (colon0 (string-find str #\:)) (colon - (and (string-cursor>=? - (string-find str char-uri-scheme-unsafe? start colon0) - colon0) - (string-cursor=? + (string-find str char-uri-scheme-unsafe? start colon0) + colon0) + colon0 + end))) (if (string-cursor>=? colon end) (and scheme (let* ((quest (string-find str #\?)) diff --git a/tests/uri-tests.scm b/tests/uri-tests.scm index 62dec819..c8e3d13a 100644 --- a/tests/uri-tests.scm +++ b/tests/uri-tests.scm @@ -53,4 +53,13 @@ (test '(("a" . "1") ("b" . "2 2") ("c" . "3")) (uri-query (string->uri "http://google.com/%73?a=1&b=2+2;c=%33" #t #t))) +(let ((str "/")) + (test-assert (uri? (string->path-uri 'http str))) + (test 'http (uri-scheme (string->path-uri 'http str))) + (test #f (uri-host (string->path-uri 'http str))) + (test #f (uri-port (string->path-uri 'http str))) + (test "/" (uri-path (string->path-uri 'http str))) + (test #f (uri-query (string->path-uri 'http str))) + (test #f (uri-fragment (string->path-uri 'http str)))) + (test-end)