Skip to content

Instantly share code, notes, and snippets.

@damienlaughton
Created March 15, 2017 16:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save damienlaughton/d6221f61123a1e60fc05fb93037467a9 to your computer and use it in GitHub Desktop.
Save damienlaughton/d6221f61123a1e60fc05fb93037467a9 to your computer and use it in GitHub Desktop.
parse a URL for a specific parameter value
//
// 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