$ show johnste/finicky
Finicky is a macOS application that acts as a smart default browser handler. It intercepts URL open requests from the operating system and routes them to different browsers based on user-defined rules written in JavaScript or TypeScript, or via a simpler JSON rules file. The application is built as a hybrid of Go (using a custom Go-like language with Objective-C interop) and a Svelte-based web UI embedded via WKWebView. It includes a JavaScript virtual machine (goja) to evaluate user configuration scripts, supports URL rewriting, short URL resolution, browser profile detection, and provides a graphical configuration and testing interface. The codebase is well-structured with separate packages for the config API (TypeScript, compiled to JS), the UI (Svelte), and the core macOS app (Go/Objective-C). It demonstrates strong engineering practices including caching, debouncing, and comprehensive testing.
The LLM identified 4 files worth highlighting for reuse:
Implements a custom wildcard matching algorithm that supports `*` as a non-greedy wildcard, escaped asterisks (`\*`), and protocol-relative patterns. It converts wildcard patterns to regular expressions with proper escaping and anchoring. This is a self-contained utility with no internal dependencies, thoroughly tested, and could be reused in any project requiring URL or string pattern matching.
Resolves shortened URLs by following HTTP redirects (HEAD then GET fallback) with a configurable timeout and redirect limit. Uses an embedded list of known shortener domains. The logic is self-contained and could be extracted as a library for URL resolution in other projects, with only minor decoupling from the internal logging.
Defines the complete configuration schema using Zod, including URL matchers (string, regex, function), browser specifications (string, object, function), rewrite rules, and handler rules. It generates TypeScript type definitions via @duplojs/zod-to-typescript. This is a well-structured, self-contained schema definition that demonstrates advanced Zod usage and could be reused as a template for configuration validation in other projects.
Implements a persistent cache for bundled configuration files with version-aware invalidation, cleanup of old cache files, and deterministic file naming based on content hashes. It handles cache persistence across app restarts and gracefully degrades when cache files are missing or outdated. This is a reusable caching pattern applicable to any application that needs to cache derived build artifacts.