Open qiaokang0 opened 4 years ago
I can confirm this behavior.
I won't be able to spend time investigating this until next week at the earliest, so here are my initial notes in case someone wants to take a look at it sooner:
hs.urlevent.openURL
, after going through a wrapper function that I have confirmed does not damage the input in any way, resolves to hs.urlevent.openURLWithBundle
. The relevant code is at https://github.com/Hammerspoon/hammerspoon/blob/master/extensions/urlevent/internal.m#L301-L308
NSURL *url = [NSURL URLWithString:[skin toNSObjectAtIndex:1]];
if (url) {
result = [[NSWorkspace sharedWorkspace] openURLs:[NSArray arrayWithObject:url]
withAppBundleIdentifier:[NSString stringWithUTF8String:lua_tostring(L, 2)]
options:NSWorkspaceLaunchDefault additionalEventParamDescriptor:nil
launchIdentifiers:nil];
}
I don't know yet if NSURL
is having issues with the characters being unencoded (though the HTTP spec doesn't require them to be since they are valid UTF-8 and don't match any of the special codes for GET URLs) or with NSWorkspace
's openURLs:withAppBundleIdentifier:options:additionalEventParamDescriptor:launchIdentifiers:
. It should be noted that this method for NSWorkspace
is deprecated in 10.15, but since Hammerspoon tries to support at least the latest three versions of macOS, even if the best solution involves using the newer NSWorkspace methods, code should be implemented to do so in a way that falls back (and ideally also fixes this for that implementation) for earlier macOS versions.
It helps. Thank you for offering this method!
I want create a workflow to search the text i input in dialog, since the url parameter for key words to search in google(if the keyword is "中国") is "https://www.google.com/search?q=中国" so i run this function in lua:
it works fine if i insert English,but no lucky with Chinese.
now i come up with a alternative solution :
this works fine in both English and Chinese