0

I would like to send a REST get with a resource and passing a query with special characters inside. I don't have the choice and need to use it.

For example :

var query = 'firstParam:*firstparam*+path:\\/path\\/to\\/folder*';
myRestService.search(query).file();

Here is the method called by the second line :

this.search = function(query){
        var url = config.domain + 'search/';
        var methods = resource(url, null, { 
            'file': {                    
                method:'GET', 
                params: { 'q': query },
                headers:{'x-ufapi-workspace' : 'TESTWS', 'Accept' : 'application/json'/*, 'ufapi-details':'attr'*/}
            }
        });
        return methods;
    };

So I have issues using + replaced by and \/ replaced by %2B and %5C%2F*. So my API doesn't understand my query.

I found that I could change the angular source code here but I don't think it is a good solution.

stop angular.js from rewriting "+" to "%2B" in url

What do you think I could do?

Community
  • 1
  • 1
BastienSander
  • 1,718
  • 4
  • 24
  • 50

1 Answers1

0

In you API in first step you can decode you url using same rules as angular coding url, before sending to API

sylwester
  • 16,498
  • 1
  • 25
  • 33