Repository navigation
feat: reopen URLs with Preferis through the preferis: scheme - #52
Merged
Merged
Conversation
Add the preferis: URL scheme, so that a browser (a bookmarklet, an extension) or any app that can open URLs hands a URL back to Preferis to route with the rules. Two forms are accepted: - preferis://open?url=<percent-encoded URL> - preferis:<URL>, with the URL as it is Only http and https URLs are carried: web pages can open preferis: URLs, and another scheme could reach the system default handler through the rules and start a program. The open form refuses anything besides its url parameter, so that a URL that was not encoded is not opened cut short at its first & or #. When no URL can be taken out, the Router logs why (input masked) and shows it in a message box in the configured language. The URL taken out is routed as any other, as opened by the app that opened the preferis: URL, and is what the history records. --dry-run and the test page of the settings route it too. Windows registers HKCU\Software\Classes\preferis with --register (and removes it with --unregister); a registration without it counts as not registered, so the settings offer Make Default to an older registration. macOS declares the scheme in the Router's CFBundleURLTypes. Documented in Design.ja.md §5.5 and Platform.ja.md §2.2 / §3.1, and on a new page of the documentation site in English and Japanese. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Summary
Adds the
preferis:URL scheme. A browser (a bookmarklet, an extension) or any app that can open URLs hands a URL back to Preferis, which routes it with the rules like any other link. It works without Preferis being the default browser.preferis://open?url=<percent-encoded URL>preferis://open?url=https%3A%2F%2Fexample.com%2F%3Fq%3D1preferis:<URL>preferis:https://example.com/?q=1Bookmarklet:
Taking the URL out (
Core.Routing.ReopenUrl)//followspreferis:. The scheme and theopenaction are case-insensitive.httpandhttpsURLs are carried. Web pages can openpreferis:URLs, and afile:URL or another scheme could reach the system default handler (ShellExecuteon Windows) through thesystemaction or a fallback, which would start a program. A nestedpreferis:URL is refused by the same rule, so nothing loops.openform refuses parameters besidesurl, a secondurland a fragment. A URL that was not encoded would otherwise open cut short at its first&or#. Values are percent-decoded only:+stays+.Routing (
RoutingService.Handle(string))appId/appPath) is the app that opened thepreferis:URL, usually the browser, so a rule can send pages coming back from Chrome to Firefox.HandleResult.Url).--dry-runand the test page of the settings route the URL taken out too.Registration
--registerwritesHKCU\Software\Classes\preferis(URL Protocol,"<Preferis.exe>" --single-argument %1), and--unregisterremoves it. Only Preferis handles the scheme, so it is not among theURLAssociationsand nothing is chosen in Settings.preferiskey is missing or points elsewhere counts as not registered. After the update, the settings offer Make Default again. It re-registers and, when http / https already are Preferis, does not open the Settings page.Info.plistdeclarespreferisin its ownCFBundleURLTypesentry. Launch Services delivers it as an Apple Event, like http / https.Docs
docs/Design.ja.md§5.5 (new), §4.3, §5.1, §10, §13docs/Platform.ja.md§2.2, §3.1reopen-with-preferisin English and JapaneseTest plan
dotnet test Preferis.Windows.slnf -p:Platform=x64: Core 651, Platform 133, Settings.Core 247, all passed.dotnet buildof the filter has 0 warnings.Preferis.exe --dry-runwith both forms routes the URL inside, and refuses afile:URL and an unencodedopenURL.preferis:link or the bookmarklet in a browser opens the URL inside it through the rulespreferis:URL from a browser and withopen 'preferis:https://example.com/'🤖 Generated with Claude Code