diff --git a/src/Url/Parser.elm b/src/Url/Parser.elm index 4a9f4c9..83b43ae 100644 --- a/src/Url/Parser.elm +++ b/src/Url/Parser.elm @@ -1,6 +1,6 @@ module Url.Parser exposing ( Parser, string, int, s - , (), map, oneOf, top, custom + , (), map, oneOf, top, custom, remainder , (), query , fragment , parse @@ -23,7 +23,7 @@ This module is primarily for parsing the `path` part. @docs Parser, string, int, s # Path -@docs (), map, oneOf, top, custom +@docs (), map, oneOf, top, custom, remainder # Query @docs (), query @@ -156,6 +156,23 @@ custom tipe stringToSomething = [] +{-| Parse all remaining path segments as a `List String`. + + blog : Parser (List String -> a) a + blog = + s "blog" remainder + + -- /blog ==> [] + -- /blog/hello ==> [ "hello" ] + -- /blog/hello/world ==> [ "hello", "world" ] +-} +remainder : Parser (List String -> a) a +remainder = + Parser <| + \{ unvisited, params, frag, value } -> + [ State [] params frag (value unvisited) ] + + -- COMBINING PARSERS