restangular icon indicating copy to clipboard operation
restangular copied to clipboard

If the url contains query parameters with a ? restangular adds a trailing slash, when it shouldn't

Open shazzababs opened this issue 12 years ago • 3 comments

Restangular is adding an additional trailing slash in the middle of URL's that contain query parameters:

eg:

var get_params = { page:1,
                            page_size:25 };

var promise = Restangular.all("jobs/?triggered_by_job=263441").getList(get_params);

The resulting URL is:

http://localhost:8000/jobs/?triggered_by_job=263441/&page=1&page_size=25

When it needs to be:

http://localhost:8000/jobs/?triggered_by_job=263441&page=1&page_size=25

(Notice the additional trailing slash after the job=263441).

This url returns a 404 error as it is incorrect syntax.

The code has obviously noticed that there are query parameters in the URL as it hasn't added a second question mark, so is it possible to not put the slash in too please!

NB: I realise I could add triggered_by_job:263441 to get_params, and I will if I have to, but I'd rather not have to manipulate the URL if I can get away with it.

shazzababs avatar Jan 24 '14 09:01 shazzababs

Hey,

Thanks for the report!

Do you have a request suffix set?

mgonto avatar Jan 24 '14 17:01 mgonto

Hi,

Yes we are using '/' as a request suffix.

shazzababs avatar Jan 27 '14 08:01 shazzababs

Then, you're going to need to send the requestParams as part of the get_params. That way, the request suffix will be added correctly, since where you are putting them isn't meant for that. Sorry about this.

Thanks!

mgonto avatar Jan 27 '14 14:01 mgonto