Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add query string support #301

Closed
wants to merge 16 commits into from
Closed

Add query string support #301

wants to merge 16 commits into from

Conversation

shawnbot
Copy link

This PR adds support for query string parameters in the URL. It introduces a query property on Router instances that stores the last parsed query string, e.g.:

var router = new Router({
  '/foo': function() {
    assert.deepEqual(this.query, {bar: 'baz', qux: true});
  }
});
router.init();
router.setRoute('/foo?bar=baz&qux');

If the path doesn't include a ?, then this.query === null.

I've included a very rudimentary query string parser in Router.prototype.parseQuery that handles the most common forms of query string parameters:

  • x parses to {x: true}
  • x=y parses to {x: 'y'}
  • x==y parses to {x: '=y'}
  • x=1&x=2 parses to {x: ['1', 2']}

I wanted to run this by y'all before I dive into the server side of things, but the basic browser tests that I've added pass. Thoughts?

@shawnbot
Copy link
Author

Eh, looks like this isn't going to get merged. Closing.

@shawnbot shawnbot closed this Dec 19, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant