0

I have a relatively simple problem here but cant find a solution to it yet. Am using Ember and calling a route with query params. The code is below.

import Ember from "ember";

export default Ember.ObjectController.extend({
    queryParams : ['user_id','custom_lis_person_name_given']
    user_id : null,
    custom_lis_person_name_given : null
});

So now lets say i am calling my Route with the following url,

localhost:4200/index.html#/route1?user_id=123456&custom_lis_person_name_given=hello

Now the values of the query params are

user_id = 123456
custom_lis_person_name_given = hello

Now if i change my url to look like

localhost:4200/index.html#/route1?user_id=12345=6&custom_lis_person_name_given=hello
localhost:4200/index.html#/route1?user_id=123456=&custom_lis_person_name_given=hello

Now the value are calculated as

user_id = 12345 or user_id=123456
custom_lis_person_name_given = hello

So basically the value ends where it sees a = sign in the query parameter value. Is there a workaround for this? i need the user_id="12345=6" or "123456="

Maybe there are some hooks in controller or route which can do this. I tried serializeQueryParam and deserializeQueryParam but it did not help.

Thanks in Advance

aneeshere
  • 75
  • 1
  • 9
  • I have one workaround by escaping the queryParamter before craeting the URL. i just did **escape('123456=')** and it worked. But in the App the url gets created in the backend. It would be better if i could fix it completely at UI side – aneeshere Feb 09 '15 at 08:17

1 Answers1

0

have you tried:

encodeURIComponent(url)

?

That one should do the work. Note that you still have to encode the = sign, so that should be the correct one.

The difference between encdeURI and encodeURIComponent is well described here: Should I use encodeURI or encodeURIComponent for encoding URLs? in the accepted answer.

EDIT:

If you want to manually edit the link and check if it works, just replace = with %3D, the result of encodeURIComponent("=").

Community
  • 1
  • 1
andrusieczko
  • 2,824
  • 12
  • 23
  • The situation is like the whole URL(ember route + query params) is generated in java file and is called in the browser. Yea so one solution is to do escape(url) from java side. But i wanted to know if there is something i could do from UI side itself. – aneeshere Feb 09 '15 at 09:17