diff --git a/Sources/Base/OAuth2Requestable.swift b/Sources/Base/OAuth2Requestable.swift index 8f601dea..c0274874 100644 --- a/Sources/Base/OAuth2Requestable.swift +++ b/Sources/Base/OAuth2Requestable.swift @@ -197,10 +197,10 @@ open class OAuth2Requestable { - returns: A dictionary full of strings with the key-value pairs found in the query */ public final class func params(fromQuery query: String) -> OAuth2StringDict { - let parts = query.characters.split() { $0 == "&" }.map() { String($0) } + let parts = query.split() { $0 == "&" }.map() { String($0) } var params = OAuth2StringDict(minimumCapacity: parts.count) for part in parts { - let subparts = part.characters.split() { $0 == "=" }.map() { String($0) } + let subparts = part.split() { $0 == "=" }.map() { String($0) } if 2 == subparts.count { params[subparts[0]] = subparts[1].wwwFormURLDecodedString } diff --git a/Sources/Flows/OAuth2CodeGrant.swift b/Sources/Flows/OAuth2CodeGrant.swift index 46e57d1f..7896d389 100644 --- a/Sources/Flows/OAuth2CodeGrant.swift +++ b/Sources/Flows/OAuth2CodeGrant.swift @@ -133,7 +133,7 @@ open class OAuth2CodeGrant: OAuth2 { if !(redirect.absoluteString.hasPrefix(expectRedirect)) && (!(redirect.absoluteString.hasPrefix("urn:ietf:wg:oauth:2.0:oob")) && "localhost" != comp?.host) { throw OAuth2Error.invalidRedirectURL("Expecting «\(expectRedirect)» but received «\(redirect)»") } - if let compQuery = comp?.query, compQuery.characters.count > 0 { + if let compQuery = comp?.query, compQuery.count > 0 { let query = OAuth2CodeGrant.params(fromQuery: comp!.percentEncodedQuery!) try assureNoErrorInResponse(query as OAuth2JSON) if let cd = query["code"] { diff --git a/Sources/Flows/OAuth2ImplicitGrant.swift b/Sources/Flows/OAuth2ImplicitGrant.swift index 4bd87563..3101f0b2 100644 --- a/Sources/Flows/OAuth2ImplicitGrant.swift +++ b/Sources/Flows/OAuth2ImplicitGrant.swift @@ -42,7 +42,7 @@ open class OAuth2ImplicitGrant: OAuth2 { do { // token should be in the URL fragment let comp = URLComponents(url: redirect, resolvingAgainstBaseURL: true) - guard let fragment = comp?.percentEncodedFragment, fragment.characters.count > 0 else { + guard let fragment = comp?.percentEncodedFragment, fragment.count > 0 else { throw OAuth2Error.invalidRedirectURL(redirect.description) }