Skip to content

Commit

Permalink
Merge pull request #1 from shipshapecode/remove-sort-query-params
Browse files Browse the repository at this point in the history
remove sort query params
  • Loading branch information
jaredgalanis authored Jan 20, 2022
2 parents f129d2b + 9c0b405 commit 3bd3b5f
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 29 deletions.
9 changes: 0 additions & 9 deletions addon/mixins/url-templates.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,15 +58,6 @@ export default Mixin.create({
return EmberObject.create(this.get('urlSegments'));
},

// HACK: Prevent query/queryRecord from appending query params to urls, we
// can do that in the template.
// TODO: ember-data plans to implement better hooks for customizing the
// request. Hopefully in the future, this hack can be removed and another
// hook used instead.
sortQueryParams(/* params */) {
return {};
},

_urlFromLink(snapshot, urlTemplate) {
if (LINK_PREFIX_RE.test(urlTemplate)) {
return this.buildURL(null, snapshot.id, snapshot, urlTemplate.replace(LINK_PREFIX_RE, ''), {});
Expand Down
20 changes: 0 additions & 20 deletions tests/acceptance/basic-url-template-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,24 +50,4 @@ module('Acceptance | basic url template', function(hooks) {
assert.equal(findAll('#post-2').length, 1);
assert.equal(findAll('#post-3').length, 0);
});

test('it prevents ember-data from adding query params', async function(assert) {
server.create('post', {
slug: 'my-first-post',
title: 'This is my first post',
});

let queryParams, params;

server.get('/my-posts/:slug', (schema, request) => {
queryParams = request.queryParams;
params = request.params;
return schema.posts.findBy({ slug: request.params.slug });
});

await visit('/posts/my-first-post');

assert.equal(params.slug, 'my-first-post');
assert.ok(!queryParams.foo);
});
});

0 comments on commit 3bd3b5f

Please sign in to comment.