This PR adds support for URL query string parameters to pathjs. While query string params are typically used to send information to an application running on a server, I ran into a use case where query string params would be very useful in the construction of a single page app.
Specifically, I wanted to give other technical teams (and myself) the ability to modify certain app-wide parameters through a simple query string key/value pair.
This PR add support for the following situations, and has the following effects:
// if this were the pathjs mapping...
pathjs.map('#/some/:id').to(function() {
console.log(this.params);
});
pathjs.rescue(function(path) {
console.log("RESCUE");
});
// we'd see the following URL -> console output
// -- http://somesite.com/#/some/10?debug
{ 'id': 10, 'debug': true }
// -- http://somesite.com/#/some/10?
"RESCUE"
// -- http://somesite.com/#/some/10?debug=false
{ 'id': 10, 'debug': false }
// -- http://somesite.com/#/some/10?debug&id=20
{ 'id': 10, 'debug': true }
// -- http://somesite.com/#/some/10?id
{ 'id': 10 }
// -- http://somesite.com/#/some/10?debug=false&debug
{ 'id': 10, 'debug': true }
Why should
#/some/10?
trigger rescue? it's just an empty query string, so it's should be the same as#/some/10