summaryrefslogtreecommitdiffstats
path: root/video
diff options
context:
space:
mode:
authorder richter <der.richter@gmx.de>2024-04-27 22:36:02 +0200
committerder richter <der.richter@gmx.de>2024-04-28 20:21:18 +0200
commit4a686dac6f2df3b1e8f0a315c41a0a79a853741b (patch)
tree85ed169aac2e70d644c6f383d60a1882964f5327 /video
parent8f1189341fcc5cddc92056078aa2439d451d1c98 (diff)
downloadmpv-4a686dac6f2df3b1e8f0a315c41a0a79a853741b.tar.bz2
mpv-4a686dac6f2df3b1e8f0a315c41a0a79a853741b.tar.xz
mac: properly handle regular expressions without force unwrap
Diffstat (limited to 'video')
-rw-r--r--video/out/mac/view.swift7
1 files changed, 4 insertions, 3 deletions
diff --git a/video/out/mac/view.swift b/video/out/mac/view.swift
index 91ace66245..4921b7512c 100644
--- a/video/out/mac/view.swift
+++ b/video/out/mac/view.swift
@@ -64,9 +64,10 @@ class View: NSView, CALayerDelegate {
}
func isURL(_ str: String) -> Bool {
- // force unwrapping is fine here, regex is guaranteed to be valid
- let regex = try! NSRegularExpression(pattern: "^(https?|ftp)://[^\\s/$.?#].[^\\s]*$",
- options: .caseInsensitive)
+ guard let regex = try? NSRegularExpression(pattern: "^(https?|ftp)://[^\\s/$.?#].[^\\s]*$",
+ options: .caseInsensitive) else {
+ return false
+ }
let isURL = regex.numberOfMatches(in: str,
options: [],
range: NSRange(location: 0, length: str.count))