evancz / url-parser

Parse URLs into nicely structured data
http://package.elm-lang.org/packages/evancz/url-parser/latest/
BSD 3-Clause "New" or "Revised" License
114 stars 29 forks source link

parseLocation doesn't handle base href values that are not "/" #54

Open justinrassier opened 6 years ago

justinrassier commented 6 years ago

The infrastructure I work with can't have a simple <base href="/"> but has to have a value such as <base href="/context/apps/my-elm-app/">

This changes the parsing logic when setting up route matchers. To get the routing to work, you have to have all the segments that are included in the base href value such as:

matchers : Parser (Route -> a) a
matchers =
    oneOf
        [ UrlParser.map Master top
        , UrlParser.map Master (UrlParser.s "context" </> s "apps" </> s "my-elm-app" </> s "master")
        , UrlParser.map Detail (s "context" </> s "apps" </> s "my-elm-app" </> s "detail" </> int)
        ]

I would expect that the path parsing would start at the segments starting after the base href value.