Repository navigation
fix: allow anchor routing on custom standard schemes (#755) - #756
Open
saudademjj wants to merge 1 commit into
Open
saudademjj wants to merge 1 commit into
saudademjj wants to merge 1 commit into
Conversation
Match url.protocol against window.location.protocol instead of hardcoding http:/https:, while explicitly rejecting file:, blob:, and opaque "null" origins. Custom standard schemes such as Electron's app:// now route internally, whereas file:// links (whose origin Chromium serializes as "file://" rather than "null"), blob: links (including inside blob: documents), mailto:, and cross-scheme links remain ignored. Fixes solidjs#755
saudademjj
force-pushed
the
saudademjj/fix-custom-scheme-anchor-links
branch
from
December 1, 2026 19:40
1e02395 to
ea641df
Compare
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.
Fixes #755.
Problem
anchorUrlinsrc/data/events.tspreviously restricted handled links tohttp:andhttps:(url.protocol !== "https:" && url.protocol !== "http:"), which was added in #581 to stopblob:URLs from slipping through the same-origin check (#382).When an app is served from a custom standard scheme (such as Electron's
app://example/viaprotocol.registerSchemesAsPrivileged({ privileges: { standard: true } }), Tauritauri://, or browser extensions),window.location.protocolis"app:"andwindow.location.originis"app://example". Every internal anchor link therefore failed the hardcodedhttp:/https:check and fell back to a full page load.Fix
Compare
url.protocolagainstwindow.location.protocolinstead of hardcodinghttp:/https:, while explicitly rejectingfile:,blob:, and opaque"null"origins:app://example/about) share bothprotocoland a non-opaqueoriginwithwindow.location, so both click navigation and link preloading work.file:is rejected explicitly because Chromium/Electron serializesfile://URL andlocationorigins as"file://"rather than"null", wherehistory.pushStatewould throwSecurityErrorafterpreventDefault().blob:is rejected explicitly so bothblob:links onhttp(s):/app:pages (handleAnchor andbloblinks #382) andblob:links insideblob:documents are ignored.mailto:,tel:,data:,javascript:, cross-scheme links, and opaque"null"origins continue to be ignored.Tests & Verification
test/data/events.spec.tscovering:app://example/) — verified failing before the fix and passing afterbasePathboundary matching onapp://example/sub/blob:app://example/...,mailto:,https://, and cross-originapp://other/links on anapp://pagefile://links with both Chromium ("file://") and opaque ("null") originsblob:links even inside ablob:documentpnpm test: 54 client test files (766 passed), 17 server test files (110 passed),tsc --project tsconfig.test.jsoncleanpnpm build:tsc,rollup -c, andcheck-fs-gate.mjscleanprettier --check: clean@solidjs/routerpatch