Hash in a GET service

1

I have a service where I make a GET request that does a search in the groups of my application, the problem is that the user created a group called #nome-do-grupo , and when it will do the search by name and it puts the hash, error search because it has no way to send the hash to the request on the server.

I tried to use encodeURIComponent but the search did not roll, I started to do a regex to remove the hashs from the string, but I would have to predict as many other characters as it can put so it was sendable.

If someone has already gone through this, how do you proceed in this case?

    
asked by anonymous 24.04.2015 / 16:59

1 answer

1

After breaking the head a little and having problems with other characters I did this function and it worked correctly:

encodeURIComponent(str).replace(/[!'()]/g, escape).replace(/\*/g, '')  
The problem I had was that after encodeURIComponent there was another script that gave escape leaving the url parameter this way %2523 (in case of hash in search) then I took this escape , then I used regex because encodeURIComponent can not 'encode' these characters ~! * () 'and in the end I gave a replace in * for nothing.

    
24.04.2015 / 20:23