| @@ -65,17 +65,6 @@ class View: NSView, CALayerDelegate { · 64 unmodified lines |
| 65 | return [] | 65 | return [] |
| 66 | } | 66 | } |
| 67 | | 67 | |
| 68 | func isURL(_ str: String) -> Bool { | | |
| 69 | guard let regex = try? NSRegularExpression(pattern: "^(https?|ftp)://[^\\s/$.?#].[^\\s]*$", | | |
| 70 | options: .caseInsensitive) else { | | |
| 71 | return false | | |
| 72 | } | | |
| 73 | let isURL = regex.numberOfMatches(in: str, | | |
| 74 | options: [], | | |
| 75 | range: NSRange(location: 0, length: str.count)) | | |
| 76 | return isURL > 0 | | |
| 77 | } | | |
| 78 | | | |
| 79 | override func performDragOperation(_ sender: NSDraggingInfo) -> Bool { | 68 | override func performDragOperation(_ sender: NSDraggingInfo) -> Bool { |
| 80 | let pb = sender.draggingPasteboard | 69 | let pb = sender.draggingPasteboard |
| 81 | guard let types = pb.types else { return false } | 70 | guard let types = pb.types else { return false } |
| @@ -89,7 +78,7 @@ class View: NSView, CALayerDelegate { · 7 unmodified lines |
| 89 | files = str.components(separatedBy: "\n").compactMap { | 78 | files = str.components(separatedBy: "\n").compactMap { |
| 90 | let url = $0.trimmingCharacters(in: .whitespacesAndNewlines) | 79 | let url = $0.trimmingCharacters(in: .whitespacesAndNewlines) |
| 91 | let path = (url as NSString).expandingTildeInPath | 80 | let path = (url as NSString).expandingTildeInPath |
| 92 | if isURL(url) { return url } | 81 | if url.isUrl() { return url } |
| 93 | if path.starts(with: "/") { return path } | 82 | if path.starts(with: "/") { return path } |
| 94 | return nil | 83 | return nil |
| 95 | } | 84 | } |