Skip to content

Commit

Permalink
[macOS] Allow open_shell to handle filenames without file://.
Browse files Browse the repository at this point in the history
  • Loading branch information
bruvzg committed Feb 9, 2024
1 parent 41564aa commit cc313a1
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion platform/macos/os_macos.mm
Original file line number Diff line number Diff line change
Expand Up @@ -356,8 +356,11 @@
Error OS_MacOS::shell_open(String p_uri) {
NSString *string = [NSString stringWithUTF8String:p_uri.utf8().get_data()];
NSURL *uri = [[NSURL alloc] initWithString:string];
// Escape special characters in filenames
if (!uri || !uri.scheme || [uri.scheme isEqual:@"file"]) {
// No scheme set, assume "file://" and escape special characters.
if (!p_uri.begins_with("file://")) {
string = [NSString stringWithUTF8String:("file://" + p_uri).utf8().get_data()];
}
uri = [[NSURL alloc] initWithString:[string stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLFragmentAllowedCharacterSet]]];
}
[[NSWorkspace sharedWorkspace] openURL:uri];
Expand Down

0 comments on commit cc313a1

Please sign in to comment.