feat: route files, other schemes, and batches instead of dropping them - #12
Merged
Conversation
Router now forwards every URL it is handed. Rules still decide http(s);
local files, unknown schemes, and paused routing go to the Default
catch-all (RoutingConfig.catchAllBrowserId). URLs are grouped by
destination so a multi-URL open reaches each browser in one call, in
arrival order.
BrowserLauncher takes URL arrays and falls back to the catch-all when the
chosen browser is missing or cannot open the items. New URLLabel gives
logs, notifications, and the popover caption one label ("index.html",
"example.com", "mailto:x@y.z", "3 items").
Info.plist declares Alternate-rank viewer types for svg, txt, js, css,
xml, png, jpeg, gif, webp, avif, and pdf, so Browseroute is an Open With
option for everything a browser renders.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Setting Browseroute as the default browser makes LaunchServices bind
public.htmlto it, so Finder hands.htmlfiles over asfile://URLs — andRouter.routesilently dropped every non-http(s)scheme. Nothing opened.Changes
Router.route(_ urls: [URL])forwards every URL it is handed. Rules still decidehttp/httpsonly; local files, unknown schemes, and paused routing go to the Default catch-all.RoutingConfig.catchAllBrowserId(default → first browser → Safari) replaces the expression that was duplicated acrossCompiledRulesandRouter.NSWorkspace.opencall and tab order matches the Finder selection.BrowserLauncher.opentakes[URL]and falls back to the catch-all when the chosen browser is missing or cannot open the items, with a notification either way.URLLabel. One label for logs, notifications and the popover caption:index.html,example.com,mailto:x@y.z,3 items.Info.plistdeclaresAlternate-rank viewer types for svg, plain-text, js, css, xml, gif, jpeg, png, webp, avif and pdf. The existing html/xhtml entry is untouched, so no default is stolen.Verification
make check: 0 SwiftLint violations, 22 tests pass. Installed the debug build to/Applications, re-registered withlsregister -f, and exercised the live app (Default catch-all = Chrome, Island rule on*.microsoft.com):.html(the reported break)Routing br-test.html -> com.google.Chrome, Chrome tabfile:///private/tmp/br-test.htmlRouting 3 items -> com.google.Chrome, three tabs in arrival orderhttps+ fileRouting br-test.html -> com.google.ChromeandRouting www.microsoft.com -> io.island.Island; Island got only the linkmailto:x@y.zRouting mailto:x@y.z -> com.google.Chrome, no error, not droppedNSWorkspace.urlsForApplications(toOpen:); png/pdf still default to Preview, txt/js to Sublime, html still to Browserouteopened == true,destination == com.apple.Safari,Browser com.nonexistent.app not found — opened in Safari, file really opened in SafariPaused2 items → Google ChromeNew unit tests cover the file-URL catch-all (a path must not be mistaken for a host),
catchAllBrowserIdprecedence, andURLLabel.Note: macOS delivers
open <url> <file>as two separateapplication(_:open:)calls, so a mixed selection yields one group per call. Grouping only ever merges what arrives together, which is what tab ordering needs.