mirror of
https://github.com/swiftbar/SwiftBar.git
synced 2024-09-19 04:08:36 +03:00
Add percent encoding to local URLs #261
This commit is contained in:
parent
e84e498c41
commit
b4ef58244b
@ -683,7 +683,7 @@ extension MenubarItem {
|
||||
}
|
||||
}
|
||||
|
||||
if let href = params.href, case let url = URL(string: href) ?? URL(fileURLWithPath: href), url.absoluteString != "." {
|
||||
if let url = params.href?.getURL(), url.absoluteString != "." {
|
||||
if params.webView {
|
||||
showWebPopover(url: url, widht: params.webViewWidth, height: params.webViewHeight)
|
||||
} else {
|
||||
|
@ -6,3 +6,19 @@ extension String {
|
||||
return "'\(self)'"
|
||||
}
|
||||
}
|
||||
|
||||
extension String {
|
||||
func getURL() -> URL? {
|
||||
if let url = URL(string: self) {
|
||||
return url
|
||||
}
|
||||
|
||||
var characterSet = CharacterSet.urlHostAllowed
|
||||
characterSet.formUnion(.urlPathAllowed)
|
||||
if let str = addingPercentEncoding(withAllowedCharacters: characterSet) {
|
||||
return URL(string: str)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user