on master help sign in
parsePath ensures non-empty in case of absolute-path.
commitb403c0fa0a64f3273d68911ee4dbe09f01be3dc5 authorKazu Yamamoto <kazu@iij.ad.jp> dateMon 4 Nov 2013, 09:27 (13 years ago) parentcaeb8d9
1 file changed+5−4
warp/Network/Wai/Handler/Warp/RequestHeader.hs+5−4
warp/Network/Wai/Handler/Warp/RequestHeader.hs+5−4
@@ -66,18 +66,19 @@ parseRequestLine s =
6666-- >>> parsePath "http://example.com:8080/path"
6767-- "/path"
6868-- >>> parsePath "http://example.com"
69−-- ""
69+-- "/"
7070-- >>> parsePath "/path"
7171-- "/path"
7272
7373-- FIXME: parsePath "http://example.com" should be "/"?
7474parsePath :: ByteString -> ByteString
7575parsePath path
76− | S.null path = "/"
77− | "http://" `S.isPrefixOf` path = extractPath path
78− | otherwise = path
76+ | "http://" `S.isPrefixOf` path = ensureNonEmpty $ extractPath path
77+ | otherwise = ensureNonEmpty $ path
7978 where
8079 extractPath = snd . S.breakByte 47 . S.drop 7 -- 47 is '/'.
80+ ensureNonEmpty "" = "/"
81+ ensureNonEmpty p = p
8182
8283----------------------------------------------------------------
8384