Fixes #2256
This commit is contained in:
Stuart Breckenridge
2020-07-13 14:24:57 +08:00
parent 88e409d2be
commit 7183b853bd
2 changed files with 10 additions and 0 deletions

View File

@@ -15,4 +15,13 @@ extension URL {
scheme == "mailto" ? URLComponents(url: self, resolvingAgainstBaseURL: false)?.path : nil
}
func valueFor(_ parameter: String) -> String? {
guard let components = URLComponents(url: self, resolvingAgainstBaseURL: false),
let queryItems = components.queryItems,
let value = queryItems.first(where: { $0.name == parameter })?.value else {
return nil
}
return value
}
}