From fdf84ef7ce611b4374d5cef3e213f155fae26914 Mon Sep 17 00:00:00 2001 From: Lukas <134181853+bo2themax@users.noreply.github.com> Date: Mon, 18 May 2026 20:40:57 +0200 Subject: [PATCH] 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. --- macos/Sources/Features/Services/ServiceProvider.swift | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/macos/Sources/Features/Services/ServiceProvider.swift b/macos/Sources/Features/Services/ServiceProvider.swift index 9bf46fcf9..2ec4e473c 100644 --- a/macos/Sources/Features/Services/ServiceProvider.swift +++ b/macos/Sources/Features/Services/ServiceProvider.swift @@ -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() } )