k1r0s / preact-routlet

Simple `Component Driven` Routing for Preact/React using ES7 Decorators
https://npm.im/preact-routlet
32 stars 2 forks source link

Implement support for QueryStrings #8

Open aalises opened 5 years ago

aalises commented 5 years ago

Currently preact-routlet does not support querystrings on the URL (e.g /testpath?foo=bar&zzz=baz). When adding them to a url, the router does not recognize the path.

It would be nice to implement recognizing querystrings on the routlet by adding another prop, search, which includes the querystring in the format this.props.search = "?param1=value1&param2=value2"

aalises commented 5 years ago

Made a pull request adding support for qs: #9

k1r0s commented 5 years ago

fair point, but why specifically querystring format?

ie: I have a component that listens to /user-list/:searchParams, so it receives params like this /user-list/name,jose otherwise /user-list/null

aalises commented 5 years ago

@k1r0s yes! We already use the path parameter parsing, they're amazing. The support for query strings is just adding more flexibility to the parsing by adding minimal change.

In our case, the backend links sometimes return URLs with query string parameters, so in-path parameters are also used within the application but we also need a way to obtain these query string parameters.