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

Pretender doesn't recognize routes with query params #31

Closed
bcardarella opened this issue Sep 4, 2014 · 3 comments
Closed

Pretender doesn't recognize routes with query params #31

bcardarella opened this issue Sep 4, 2014 · 3 comments

Comments

@bcardarella
Copy link

Failing test:

test("can register queryParam urls", function(){
  var queryCalled  = false;
  var noQueryCalled = false;
  pretender.get('/some/path?a=1&b=2', function(request){
    queryCalled = true;
  });
  pretender.get('/some/path', function(request){
    noQueryCalled = true;
  });

  $.ajax({url: '/some/path?a=1&b=2'});
  ok(!noQueryCalled, 'should be false');
  ok(queryCalled, 'should be true');
});

I have tracked the problem down to RouteRecognizer: https://github.com/tildeio/route-recognizer/blob/master/lib/route-recognizer.js#L475-L523

It appears that RotueRecognizer will register the original path along with the queryParams. However in the linked function above the queryParams are striped from the path and no handler is found for the truncated path.

My use-case is https://github.com/dockyard/ember-cli-proxy-fixtures. This module is recording request responses during the test suite for faster playback via Pretender on future runs.

@k-dauda
Copy link

k-dauda commented Sep 11, 2014

I think this should solve your problem.
pretender.get('/some/path', function(request) {
queryCalled = !_.isEmpty(request.queryParams);
});

@trek
Copy link
Member

trek commented Jan 17, 2015

Can you open this on the route recognize repo? This isn't a feature we can support without a change there.

@trek trek closed this as completed Jan 17, 2015
@ghost
Copy link

ghost commented Aug 25, 2015

For reference tildeio/route-recognizer#53.

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

No branches or pull requests

3 participants