FacultyCreative / ngActiveResource

Connects business objects and REST web services for Angular.js
255 stars 34 forks source link

Query String Trailing Slash #22

Closed brayniverse closed 10 years ago

brayniverse commented 10 years ago

If you append a trailing slash to the url like you do in this function:

function appendSlashForQueryString(url) {
  if (url.slice(-1) == '/') return url;
  return url + '/';
};

It seems to prevent developers from using custom query string parameters like so.


Dashboard.api.showURL = 'http://localhost:8000/api/dashboards/:id/?embed=:embed';

Dashboard.find({
  id: $routeParams.id,
  embed: 'widgets,users'
}).then(function (dashboard) {
  // ...
});

Which results in the following http://localhost:8000/api/dashboards/1/?embed=widgets,users/

I can't speak for others but I sometimes need to pass query string parameters to my server, maybe to paginate results or to define what resources to embed. If the trailing slash isn't necessary I can send a pull request your way.

brettshollenberger commented 10 years ago

Look into it; I think the reason it was added in the first place is because the $http method doesn't automatically add the slash before parsing to query string, and I found the slash-then-querystring to be more common than not. Thanks for all your hard work on this, @brayniverse

brettshollenberger commented 10 years ago

@brayniverse, this change is fixed on 0.7.3