0

I am currently creating a search function in AngularJS 1. I am using Restangular in order to communicate between my JS frontend and an API.

I was wondering however, does AngularJS or Restangular in particular, strip out certain characters from my request?

I am doing a get request as follows using Restangular:

Restangular.all('details').get(detail_id).then(function(detailResult) { // etc...

However this works if detail_id is set to: 2019 but when detail_id is set to: 2019#1

Then Restangular (I assume) automatically strips off the #1 and I don't see this on the server side.

Am I making a mistake here or is this a limitation to Get requests with Restangular or alternatively is this working as intended and I have missed something?

Any help is appreciated, Thanks

1 Answer 1

1

This is by design. The part after the # is called the fragment, and is it never sent to the server since it is supposed to be used on the client side only.

Per Wikipedia's article on the subject:

The fragment identifier functions differently than the rest of the URI: namely, its processing is exclusively client-side with no participation from the web server

If # is actually part of the id, you'd need to url encode the parameter like this:

Restangular.all('details').get(encodeURIComponent(detail_id)).then(function(detailResult) { // etc...
Sign up to request clarification or add additional context in comments.

2 Comments

Thanks! I will likely just url encode the param and url decode it or use a post request.
Worked perfectly thanks! Didn't know about the fragment identifier!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.