Skip to content

Commit

Permalink
👍REFACTOR: percentEncodePlusSign 메서드 분리 #30
Browse files Browse the repository at this point in the history
  • Loading branch information
yeahg-dev committed Mar 17, 2023
1 parent d67900b commit 24909ab
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,23 @@ struct CountryCodeListRequest: APIRequest {
var urlComponents = URLComponents(string: baseURLString + path)
urlComponents?.queryItems = query.map {
URLQueryItem(name: $0.key, value: "\($0.value)") }
let encodedQuery = urlComponents?.percentEncodedQuery?.replacingOccurrences(of: "+", with: "%2B")
urlComponents?.percentEncodedQuery = encodedQuery
return urlComponents?.url
let encodedUrlComponents = percentEncodePlusSign(urlComponents)
return encodedUrlComponents?.url
}

init(pageNo: Int, numOfRows: Int) {
self.query = ["serviceKey": Bundle.main.countryCodeAPIKey,
"numOfRows": numOfRows,
"pageNo": pageNo]
}

private func percentEncodePlusSign(_ urlComponents: URLComponents?) -> URLComponents? {
var encodedUrlComponents = urlComponents
let encodedQuery = urlComponents?.percentEncodedQuery?.replacingOccurrences(
of: "+",
with: "%2B")
encodedUrlComponents?.percentEncodedQuery = encodedQuery
return encodedUrlComponents
}

}

0 comments on commit 24909ab

Please sign in to comment.