fix(core): preserve leading slash when partitioning triple-slash URIs - #1865
Merged
ggrossetie merged 1 commit intoJul 30, 2026
Merged
Conversation
PathResolver#partitionPath() unconditionally filtered out every empty
segment produced by String#split('/'), including the leading empty
segment left over when a URI root under-consumes its slashes (e.g.
UriSniffRx matches at most 2 slashes after the scheme, so "file://"
is the root for "file:///Users/foo" and the 3rd slash survives as a
leading "" in the remainder). Dropping that segment made joinPath()
reassemble "file://Users/foo" instead of "file:///Users/foo" — a
malformed URL whose non-empty "host" (Users) browsers reject outright.
Mirror Ruby's String#split('/') semantics instead: only trailing
empty segments are dropped, leading/interior ones are kept.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
ggrossetie
force-pushed
the
fix/path-resolver-triple-slash-uri
branch
from
July 30, 2026 13:12
cff7878 to
ee383ba
Compare
ggrossetie
added a commit
to asciidoctor/asciidoctor-browser-extension
that referenced
this pull request
Jul 31, 2026
Route the warning through doc.getLogger() instead of console.warn, and drop the outdated XMLHttpRequest/Manifest V3 explanation since fetch is now used. Note the real cause (readAsset losing the leading / on file:// URLs, see asciidoctor/asciidoctor.js#1865) as a FIXME. Co-Authored-By: Claude Sonnet 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.
PathResolver#partitionPath()unconditionally filtered out every empty segment produced by splitting a path on/, including the leading empty segment left over when a URI root under-consumes its slashes.UriSniffRxmatches at most 2 slashes after the scheme, so forfile:///Users/guillaume/foo.png, the root captured isfile://and the 3rd slash survives as a leading""in the remainder passed topartitionPath().Dropping that empty segment made
joinPath()reassemblefile://Users/guillaume/foo.pnginstead offile:///Users/guillaume/foo.png— a malformed URL whose non-empty "host" (Users) browsers reject outright withNot allowed to load local resource. This surfaced in the asciidoctor-chart browser extension when resolvingfile://asset targets, but affects any consumer that resolves afile:///-style absolute path throughPathResolver.The fix mirrors Ruby's
String#split('/')semantics, which the original Ruby-to-JS port didn't replicate: Ruby's split drops only trailing empty strings from the result, keeping leading/interior ones. The JS port instead dropped all of them unconditionally.partitionPath()now only trims trailing empty segments, so the leading placeholder segment survives andjoinPath()correctly reconstructs the missing slash.Added regression tests covering
partitionPath()andexpandPath()on triple-slashfile://URIs (including with a..segment to resolve), and confirmedhttp://-style URIs with a real authority are unaffected.