macOS: check the resource the URL refers to.
Fixes #12727. [`NSURL.hasDirectoryPath` doesn't do this](https://developer.apple.com/documentation/foundation/nsurl/hasdirectorypath). We don't need to check this in NewTerminalIntent since AppIntent already appends `/` to the directory.pull/12731/head
parent
4b7bf0b20e
commit
fdf84ef7ce
|
|
@ -42,7 +42,13 @@ class ServiceProvider: NSObject {
|
|||
// to their directories because that's the only thing we can open.
|
||||
let directoryURLs = Set(
|
||||
pathURLs.map { url -> URL in
|
||||
url.hasDirectoryPath ? url : url.deletingLastPathComponent()
|
||||
/// We check file system resources here because
|
||||
/// NSURL doesn't append `/` when reading string contents from pasteboard
|
||||
/// ```
|
||||
/// NSURL(pasteboardPropertyList: "/System/Library".propertyList(), ofType: .fileURL)?.hasDirectoryPath
|
||||
/// ```
|
||||
let isDirectory = (try? url.resourceValues(forKeys: [.isDirectoryKey]))?.isDirectory ?? url.hasDirectoryPath
|
||||
return isDirectory ? url : url.deletingLastPathComponent()
|
||||
}
|
||||
)
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue