Moya: Why is my character converted?

Created on 4 Apr 2018  路  3Comments  路  Source: Moya/Moya

I'm using the 11.0.1 version
My code


extension MainMoyaAPI: TargetType {
    public var baseURL: URL {
        return URL(string: "http://www.mainmoya.com")!
    }

    public var path: String {
        switch self {
        case .login(_):
            return "/login.do?key=\(iOS_Key)"
        case .cityList(_):
            return "/getCity"
        }
    }
// More ....
}

The string "/login.do?key=(iOS_Key)" is converted to "/login.do%3Fkey=(iOS_Key)"
Right is "http://www.mainmoya.com/login.do?key=(iOS_Key)"

Thinks

question

All 3 comments

@PlutusCat It's because ? is not meant to be used in path and this is what causes it to get encoded this way. You could move the ? into baseURL and it should fix your issue.

Related:

1198

1129

1030

1119

1121

1059

969

@jdisho Thanks for helping us clean up! But we actually have a bot that automatically closes an issue after 2 weeks of inactivity 馃槆

@PlutusCat We're glad you were able to resolve your issue. Mind letting us know how you managed to fix this? It could help a future Moya user

Was this page helpful?
0 / 5 - 0 ratings