Skip to content

Commit

Permalink
request url setting cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
dmcyk committed Jan 22, 2017
1 parent 007a542 commit be14299
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions Sources/SwiftyCurl/cURLConnection.swift
Original file line number Diff line number Diff line change
Expand Up @@ -181,23 +181,20 @@ open class cURLConnection {

func setURLFrom(request: cURLRequest) throws {

guard let cmp = URLComponents(url: request.url, resolvingAgainstBaseURL: true), let rawString = cmp.string else {
guard let cmp = URLComponents(url: request.url, resolvingAgainstBaseURL: true),
var urlString = cmp.string else {
throw Error.incorrectURL
}

var urlString: String = rawString

if let portValue = cmp.port {
urlString = urlString.replacingOccurrences(of: ":\(portValue)", with: "")
urlString = urlString.replacingOccurrences(of: ":\(portValue)", with: "")
self.port = portValue
} else {
self.port = nil
}

self.url = urlString

if let port = cmp.port {
self.port = port
} else {
self.port = nil
}
}

open func request(_ req: cURLRequest) throws -> cURLResponse {
Expand Down

0 comments on commit be14299

Please sign in to comment.