Closed stroborobo closed 6 years ago
If you know the prefix ahead of time you can embed it in the parser combinator:
s "foo" </>
+ the rest of the combinator
if you don't know what it is, you can grab it with str
(assuming everything else matches). Ignore it or capture, whatever...
makes sense?
You shouldn't need internal implementation details of the parser, nor parseWithPrefix
- just adjust the parser, construct it with the configuration you clearly heave from somewhere if you must, but I think we can close it at this point.
Description
Hey Elmish team :)
What if you're serving your app from
/foo/
instead of just/
? Since the Parser passed toProgram.toNavigatable
isLocation -> 'a
it cannot know any possible configuration that's inside of your model. I understand that the parser is called before the user'sinit
is called, so there's no initial model yet.I don't know how to tackle this issue really, for now I put a
window.__BASE_PATH__
string into our HTML when the SSR runs and apply it to my parser beforehand so I can cut it out if thelocation.pathname
. For that I copiedUrlParser.parseParams
andUrlParser.toKeyValuePair
btw because they're not public.Ideas?
Maybe a helper function like
UrlParser.parsePathWithPrefix : string -> Location -> 'a
would already suffice?Related information