Should buildURL be looking for trailing slashes?

Currently, I’m working with a REST API that has the following convention for routes:

  • Collection routes have an appended trailing slash (i.e. ../animals/)
  • Single routes do NOT have an appended trailing slash (i.e. .../animals/1)

What Ember-Data currently expects is no trailing slashes (REST Conventions) and therefore when working with them it appends the id after inputting a trailing slash, resulting in an extra forward slash: ../animals//1

While I have currently extended the RESTAdapter’s buildURL method to look out for these use cases, I have been wondering if it is Ember’s responsibility to look for these checks by default.

Just in case anyone still interested in this:

I had the same problem, but instead of extending the whole buildURL function I’ve overwrite the findAll function of my adapter (ÀctiveModelAdapter) so that it appends an extra / only when looking for all records.

It is not full tested, it could have some little problems if you’re passing parameter to search but it should works fine.

Could you submit an issue/failing test/a PR with the solution to the https://github.com/emberjs/data ?

Rigth now I’ve only the function code, no tests or anyting … :non-potable_water:

As soon as I can write it better I’ll submit it. In the mean while, extend or reopen your adapter and:

findAll: function(store, type, sinceToken) {
  var query;

  if (sinceToken) {
    query = { since: sinceToken };
  }

  return this.ajax(this.buildURL(type.typeKey)+'/', 'GET', { data: query });
},

I don’t like to have rewritten the whole function, I’d rather try to use this.__super() but since the function is returning an ajax request I’m not sure how to do it…