Created
February 21, 2022 15:29
-
-
Save dbonates/b71094d58bf80fba869252ba716e0785 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extension String { | |
func queryParameter(_ parameter: String) -> String? { | |
var fields = [String: String]() | |
params.components(separatedBy: "&").forEach { | |
let field = $0.components(separatedBy: "=") | |
fields[String(field.first ?? "")] = String(field.last ?? "") | |
} | |
return fields[parameter] | |
} | |
} | |
// use | |
let val = params.queryParameter("teste") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment