Skip to content

Instantly share code, notes, and snippets.

@hishma
Created March 19, 2019 23:26
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 hishma/8e3e951561a7cce2ec12d9c3d2ee2746 to your computer and use it in GitHub Desktop.
Save hishma/8e3e951561a7cce2ec12d9c3d2ee2746 to your computer and use it in GitHub Desktop.
import Foundation
extension URL {
public mutating func deleteQuery() {
self = self.deletingQuery()
}
public func deletingQuery() -> URL {
guard var components = URLComponents(url: self, resolvingAgainstBaseURL: false) else { return self }
components.query = nil
return components.url ?? self
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment