alexmingoia / purescript-pux

Build type-safe web apps with PureScript.
https://www.purescript-pux.org
Other
566 stars 76 forks source link

Add matcher to ignore the rest of the path. #144

Closed ravloony closed 6 years ago

ravloony commented 7 years ago

We have a Pux application that can be embedded in any page. It has a backend component that is embedded in an admin area like /admin/page.

The application itself only uses the query params as the php backend handles the whole url.

So I have added a function that matches any number of url segments, to avoid having to repeat myself.

As an aside for posterity, I came up with this while debugging behaviour where having a trailing slash before the query string was causing my route matching to fail. This is because someurl/page/?param=something and someurl/page?param=something are parsed into

(Cons Path "someurl" (Cons Path "" (Cons Query (M.Map "param" "something") Nil ) ) )

and

(Cons Path "someurl" (Cons Query (M.Map "param" "something") Nil) )

respectively, due to the behaviour of S.split (S.Pattern "/") in routeFromUrl.

syaiful6 commented 7 years ago

i prefer the original behaviour, because someurl/page/?param=something is different with someurl/page?param=something.

alexmingoia commented 7 years ago

I'd prefer to just remove the router from Pux altogether, as purescript-routing provides most of the same functionality.

ravloony commented 6 years ago

Have been playing around with purescript-routing in the meantime. It does seem to provide all the functionality, so you're probably right. I still think this should be merged though, as it does not change existing functionality and is useful in its own right.

ravloony commented 6 years ago

@syaiful6 I haven't changed existing functionality, only added more.