Moya / Moya

Network abstraction layer written in Swift.
https://moya.github.io
MIT License
15.09k stars 1.98k forks source link

"&" character in path isn't encoded properly #2142

Open CameronHamidi opened 3 years ago

CameronHamidi commented 3 years ago

Using most recent version of Moya

I want to make a request to a route that has an "&" character in it. Moya by default will not encode this character, so for example if my custom target type looks like this:

extension CustomAPI: TargetType {
    var path = "/something&something"
    ...

and I get the path of the resulting target, it looks like "/something&something". My backend requires that ampersands are replaced with "%26". However, if I do

extension CustomAPI: TargetType {
    var path = "/something%26something"
    ...

Moya encodes the % as %25, even though it wouldn't encode the ampersand. So in turn the path is now "%2625".

Is there anyway to choose which characters get encoded?

stale[bot] commented 3 years ago

This issue has been marked as stale because it has not had recent activity. It will be closed if no further activity occurs.