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,24 @@ 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 ==> Just []
166+ -- /blog/hello ==> Just [ "hello" ]
167+ -- /blog/hello/world ==> Just [ "hello", "world" ]
168+ -- /foo/bar ==> Nothing
169+ -}
170+ remainder : Parser (List String -> a ) a
171+ remainder =
172+ Parser <|
173+ \ { unvisited, params, frag, value } ->
174+ [ State [] params frag ( value unvisited) ]
175+
176+
159177
160178-- COMBINING PARSERS
161179
0 commit comments