Permalink
Browse files

Don't parse slashes in strings

  • Loading branch information...
1 parent cbbdfe0 commit 6d7482319e70aa7a11dbdea4c73cd2aa0d507a92 @tomlokhorst committed Jul 8, 2011
Showing with 8 additions and 3 deletions.
  1. +8 −3 Web/Zwaluw.hs
View
@@ -108,9 +108,14 @@ int = readshow
integer :: Router r (Integer :- r)
integer = readshow
--- | Routes any string.
+-- | Routes any string, upto a slash ("/").
string :: Router r (String :- r)
-string = val (\s -> [(s, "")]) (return . (++))
+string = val parse' serialize
+ where
+ parse' s = [( takeWhile (/= '/') s
+ , dropWhile (/= '/') s
+ )]
+ serialize = return . (++)
-- | Routes one character satisfying the given predicate.
satisfy :: (Char -> Bool) -> Router r (Char :- r)
@@ -175,4 +180,4 @@ rMaybe r = rJust . r <> rNothing
$(deriveRouters ''Bool)
rTrue :: Router r (Bool :- r)
-rFalse :: Router r (Bool :- r)
+rFalse :: Router r (Bool :- r)

0 comments on commit 6d74823

Please sign in to comment.