Created
March 15, 2017 16:33
-
-
Save damienlaughton/d6221f61123a1e60fc05fb93037467a9 to your computer and use it in GitHub Desktop.
parse a URL for a specific parameter value
This file contains 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
// | |
// URL+Parameters.swift | |
// Created by Damien Laughton on 15/03/2017. | |
// | |
import Foundation | |
extension URL { | |
func value(for paramater: String) -> String? { | |
let queryItems = URLComponents(string: self.absoluteString)?.queryItems | |
let queryItem = queryItems?.filter({$0.name == paramater}).first | |
let value = queryItem?.value | |
return value | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment