fix(scripts): decode file:// URLs so a checkout path with spaces works - #23
Open
john-the-dev wants to merge 1 commit into
Open
fix(scripts): decode file:// URLs so a checkout path with spaces works#23john-the-dev wants to merge 1 commit into
john-the-dev wants to merge 1 commit into
Conversation
`new URL(...).pathname` returns a percent-encoded path, so any checkout whose
directory contains a space resolves to a name that does not exist. Both entry
points hit it:
scripts/lib.mjs:12 ENTRIES_DIR = new URL("../entries/", import.meta.url).pathname
scripts/build.mjs:10 DIST = new URL("../dist/", import.meta.url).pathname
`fileURLToPath()` is the API that decodes, and is what Node documents for this
conversion.
Measured from a checkout under ".../Application Support/...":
before validate.mjs rc=1 ENOENT ... /Application%20Support/...
build.mjs rc=1 ENOENT ... /Application%20Support/...
after validate.mjs rc=0 59 entries valid, 48 warnings
build.mjs rc=0 Built dist/kb.json — 59 entries
CI is unaffected either way — its checkout path has no spaces — so this only
ever showed up locally, which is also why it survived.
Co-Authored-By: Claude Opus 5 (1M context) <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.
Follow-up to the incidental finding in #22, as offered there.
The bug
new URL(...).pathnamereturns a percent-encoded path. Any checkout whose directory contains a space then resolves to a name that does not exist. Both entry points have it:fileURLToPath()is the documented conversion and decodes correctly.Evidence
From a checkout under
.../Application Support/..., same path both runs:build.mjswas failing for the same reason and would have kept failing after alib.mjs-only fix — worth fixing both rather than the one that surfaced.Scope
Two lines plus two imports.
dist/is deliberately not included: runningbuild.mjsto verify regenerates it, and a rebuilt artifact does not belong in a fix commit — I restored it before committing.CI is unaffected either way, since its checkout path has no spaces. That is also why this survived: the failure is invisible to the only environment that runs the scripts automatically.