Skip to content
Browse files

Don't match empty strings or texts, as this is rarely expected behaviour

  • Loading branch information...
1 parent f322bf9 commit eacc4d46cab794cda88b66b6775f54d598154132 @tomlokhorst committed Jul 9, 2011
Showing with 10 additions and 8 deletions.
  1. +10 −8 Web/Zwaluw.hs
View
18 Web/Zwaluw.hs
@@ -109,22 +109,24 @@ int = readshow
integer :: Router r (Integer :- r)
integer = readshow
--- | Routes any string, upto a slash ("/").
+-- | Routes any non-empty string, upto a slash ("/").
string :: Router r (String :- r)
string = val parse' serialize
where
- parse' s = [( takeWhile (/= '/') s
- , dropWhile (/= '/') s
- )]
+ parse' "" = []
+ parse' s = [( takeWhile (/= '/') s
+ , dropWhile (/= '/') s
+ )]
serialize = return . (++)
--- | Routes any text, upto a slash ("/").
+-- | Routes any non-empty text, upto a slash ("/").
text :: Router r (T.Text :- r)
text = val parse' serialize
where
- parse' s = [( T.pack . takeWhile (/= '/') $ s
- , dropWhile (/= '/') s
- )]
+ parse' "" = []
+ parse' s = [( T.pack . takeWhile (/= '/') $ s
+ , dropWhile (/= '/') s
+ )]
serialize = return . (++) . T.unpack
-- | Routes one character satisfying the given predicate.

0 comments on commit eacc4d4

Please sign in to comment.
Something went wrong with that request. Please try again.