Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OAuthSwiftClient fix #70

Closed
ozgurersil opened this issue May 27, 2015 · 1 comment
Closed

OAuthSwiftClient fix #70

ozgurersil opened this issue May 27, 2015 · 1 comment

Comments

@ozgurersil
Copy link

In OAuthSwiftClient.swift class:

in request function if the url contains latin chars, NSURL crashes. I fix and paste below

func request(url: String, method: String, parameters: Dictionary<String, AnyObject>, success: OAuthSwiftHTTPRequest.SuccessHandler?, failure: OAuthSwiftHTTPRequest.FailureHandler?) {
    if let url = NSURL(string: url.stringByAddingPercentEscapesUsingEncoding(NSUTF8StringEncoding)!)
    {
        let request = OAuthSwiftHTTPRequest(URL: url, method: method, parameters: parameters)
        if self.credential.oauth2 {
            request.headers = ["Authorization": "Bearer \(self.credential.oauth_token)"]
        } else {
            request.headers = ["Authorization": OAuthSwiftClient.authorizationHeaderForMethod(method, url: url, parameters: parameters, credential: self.credential)]
        }
        request.successHandler = success
        request.failureHandler = failure
        request.dataEncoding = dataEncoding
        request.encodeParameters = true
        request.start()
    }
}

thanks for the library,
it rocks

@phimage
Copy link
Member

phimage commented May 29, 2015

PR #71 opened

@dongri dongri closed this as completed in 3ea260a Jun 1, 2015
dongri added a commit that referenced this issue Jun 1, 2015
Fix #70: use `let` on `NSURL` instead of force unwrapping
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants