Skip to content

feat: route files, other schemes, and batches instead of dropping them - #12

Merged
TerrifiedBug merged 2 commits into
mainfrom
feat/route-any-url
Sep 7, 2026
Merged

feat: route files, other schemes, and batches instead of dropping them#12
TerrifiedBug merged 2 commits into
mainfrom
feat/route-any-url

Conversation

@TerrifiedBug

Copy link
Copy Markdown
Owner

Setting Browseroute as the default browser makes LaunchServices bind public.html to it, so Finder hands .html files over as file:// URLs — and Router.route silently dropped every non-http(s) scheme. Nothing opened.

Changes

  • Nothing is dropped. Router.route(_ urls: [URL]) forwards every URL it is handed. Rules still decide http/https only; local files, unknown schemes, and paused routing go to the Default catch-all.
  • One catch-all definition. RoutingConfig.catchAllBrowserId (default → first browser → Safari) replaces the expression that was duplicated across CompiledRules and Router.
  • Batches. URLs are grouped by destination in arrival order, so a multi-file open reaches each browser in a single NSWorkspace.open call and tab order matches the Finder selection.
  • Fallback on open failure. BrowserLauncher.open takes [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.
  • Open With. Info.plist declares Alternate-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.
  • Version bumped to 0.2.0; README + CHANGELOG updated.

Verification

make check: 0 SwiftLint violations, 22 tests pass. Installed the debug build to /Applications, re-registered with lsregister -f, and exercised the live app (Default catch-all = Chrome, Island rule on *.microsoft.com):

Case Result
Local .html (the reported break) Routing br-test.html -> com.google.Chrome, Chrome tab file:///private/tmp/br-test.html
Three files at once one log line Routing 3 items -> com.google.Chrome, three tabs in arrival order
Mixed https + file Routing br-test.html -> com.google.Chrome and Routing www.microsoft.com -> io.island.Island; Island got only the link
mailto:x@y.z Routing mailto:x@y.z -> com.google.Chrome, no error, not dropped
Open With Browseroute listed for all 13 declared extensions via NSWorkspace.urlsForApplications(toOpen:); png/pdf still default to Preview, txt/js to Sublime, html still to Browseroute
Missing browser throwaway test: opened == true, destination == com.apple.Safari, Browser com.nonexistent.app not found — opened in Safari, file really opened in Safari
Routing paused both items → catch-all, log lines prefixed Paused
Popover caption live screenshot reads 2 items → Google Chrome

New unit tests cover the file-URL catch-all (a path must not be mistaken for a host), catchAllBrowserId precedence, and URLLabel.

Note: macOS delivers open <url> <file> as two separate application(_:open:) calls, so a mixed selection yields one group per call. Grouping only ever merges what arrives together, which is what tab ordering needs.

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.
@TerrifiedBug
TerrifiedBug merged commit 5c413e8 into main Sep 7, 2026
1 check passed
@TerrifiedBug
TerrifiedBug deleted the feat/route-any-url branch September 7, 2026 10:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant