Hammerspoon / hammerspoon

Staggeringly powerful macOS desktop automation with Lua
http://www.hammerspoon.org
MIT License
12.08k stars 582 forks source link

hs.urlevent incorrectly treats scheme in case sensitive manner #3686

Open von opened 1 month ago

von commented 1 month ago

With Hammerspoon configured to be the default URL handler via URLDispatcher and trying to open a URL starting with "HTTPS://" I get the following error:

2024-09-10 13:14:11: 13:14:11 ERROR: urlevent: Hammerspoon has been passed a HTTPS URL, but does not know how to handle it

I.e. it looks like URLDispatcher treats "HTTPS" and "https" differently.

I believe, according to 6.2.2.1 of RFC 3986, schemes should be treated in a case-insensitive manner.

von commented 1 month ago

Looks like this is due to hs.urlevent.openURL() - simple demonstration:

> hs.urlevent.openURL("HTTPS://somehost.com/foo/bar")
true
2024-09-10 17:50:18: 17:50:18 ERROR:  urlevent: Hammerspoon has been passed a HTTPS URL, but does not know how to handle it
cmsj commented 1 month ago

Good spot, we are indeed doing a case-sensitive comparison: https://github.com/Hammerspoon/hammerspoon/blob/08cb81357dae2e9ecce33cba1a627b9dbc09af04/extensions/urlevent/urlevent.lua#L51

cmsj commented 1 month ago

(although note to anyone who might beat me to fixing this, actually the best place to do it would be in the Objective C side, by converting the scheme and host (but not the other fields) to lowercase: https://github.com/Hammerspoon/hammerspoon/blob/master/extensions/urlevent/liburlevent.m#L150 )