Repository navigation
fix(javascript): normalize package URLs before array selection - #1916
Merged
Merged
Conversation
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
3 tasks done
2 tasks done
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
Package imports and exports now normalize each relative target as a URL before deciding whether an array entry escapes the package root. A target such as
["./.\t./outside.cjs", "./fallback.cjs"]selectsfallback.cjs, matching Node, instead of losing the edge asnot-found.Follow-up to #1862 for its final review finding, posted after that PR merged.
Problem and expected behavior
The selector checked raw path segments, then committed to a string before URL normalization. Node removes tabs and newlines while constructing the URL, validates package-root containment, and skips an invalid target while array fallback is still available. Decoding and file lookup failures happen after selection and must retain the first selected target's failure.
Change and scope
The shared application selector retains the original target and its normalized URL. Imports and exports use that URL for containment and lookup, with inventory path segments encoded when constructing the package base. This also preserves package filenames containing spaces, Unicode, and URL punctuation. Failed lookups retain the original target and metadata path in their limitations.
CommonJS validates encoded separators across the selected serialized URL; ESM validates its pathname. Those errors and missing files do not select a later array entry. Wildcard expansion, recursive aliases, and external-package import targets keep their existing scope.
Contract and boundary impact
JavaScriptArtifactPathResolutiontarget selection, before array fallback is decided.Evidence and regression coverage
not-found.#tab-escapeand#newline-escapeedges toconfig.cjs; missing normalized targets retainnot-foundand their original target text.For evidence-bearing changes:
Validation performed
npm ci— passed with the pinned Node 24.18.0/npm 11.16.0 toolchain.npm run test:focused -- src/domain/javascript/javascriptPackageImportAliases.test.ts src/application/javascript/JavaScriptArtifactPathResolution.test.ts tests/boundary/javascript/packageImportAliases.test.ts tests/boundary/javascript/packageConditionalExports.test.ts tests/acceptance/applications/packageImportAliasesCli.test.ts tests/acceptance/applications/packageSubpathsCli.test.ts tests/acceptance/applications/packageJsonImports.test.ts— 225 tests passed across seven files on current main plus this commit, including compiled CLI/stdio MCP journeys.npm run check— passed, including architecture guards; zero lint errors.npm run docs:check— passed.Compatibility, safety, and release
Review checklist
type(scope): outcome.