11module Url.Parser exposing
22 ( Parser , string, int, s
3- , (</>) , map, oneOf, top, custom
3+ , (</>) , map, oneOf, top, custom, remainder
44 , ( <?> ) , query
55 , fragment
66 , parse
@@ -23,7 +23,7 @@ This module is primarily for parsing the `path` part.
2323@docs Parser, string, int, s
2424
2525# Path
26- @docs (</>), map, oneOf, top, custom
26+ @docs (</>), map, oneOf, top, custom, remainder
2727
2828# Query
2929@docs (<?>), query
@@ -156,6 +156,23 @@ custom tipe stringToSomething =
156156 []
157157
158158
159+ {- | Parse all remaining path segments as a `List String`.
160+
161+ blog : Parser (List String -> a) a
162+ blog =
163+ s "blog" </> remainder
164+
165+ -- /blog ==> []
166+ -- /blog/hello ==> [ "hello" ]
167+ -- /blog/hello/world ==> [ "hello", "world" ]
168+ -}
169+ remainder : Parser (List String -> a ) a
170+ remainder =
171+ Parser <|
172+ \ { unvisited, params, frag, value } ->
173+ [ State [] params frag ( value unvisited) ]
174+
175+
159176
160177-- COMBINING PARSERS
161178
0 commit comments