fix: strip trailing slash from resolved node builtins#556
fix: strip trailing slash from resolved node builtins#556ashtonjurgens wants to merge 2 commits into
Conversation
📝 WalkthroughWalkthroughThe PR fixes module ID resolution to strip trailing slashes from ChangesBuiltin Module Trailing Slash Normalization
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
test/env.test.ts (1)
57-70: ⚡ Quick winConsider adding a test case for
node:-prefixed IDs with trailing slashes.The test validates the core scenario (
punycode/→node:punycode), but it would be valuable to also test the case where an override maps to anode:-prefixed ID with a trailing slash (e.g.,bar: "node:punycode/"). This would explicitly exercise lines 122-128 insrc/env.tsand provide more comprehensive coverage of the fix.🧪 Suggested additional test case
it("strips trailing slash when resolving builtin aliases", () => { const { env } = defineEnv({ nodeCompat: false, resolve: true, overrides: { alias: { punycode: "node:punycode", foo: "punycode/", + bar: "node:punycode/", }, }, }); expect(env.alias.foo).toBe("node:punycode"); + expect(env.alias.bar).toBe("node:punycode"); });🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@test/env.test.ts` around lines 57 - 70, Add a test to cover node:-prefixed IDs that include a trailing slash: extend the existing test using defineEnv to include an overrides.alias mapping such as bar: "node:punycode/" and assert that env.alias.bar resolves to "node:punycode"; this will exercise the normalization logic around node: IDs (the code paths exercised by the current test for foo and the logic in the env normalization functions) and ensure trailing slashes are stripped for node: prefixed targets as well.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@test/env.test.ts`:
- Around line 57-70: Add a test to cover node:-prefixed IDs that include a
trailing slash: extend the existing test using defineEnv to include an
overrides.alias mapping such as bar: "node:punycode/" and assert that
env.alias.bar resolves to "node:punycode"; this will exercise the normalization
logic around node: IDs (the code paths exercised by the current test for foo and
the logic in the env normalization functions) and ensure trailing slashes are
stripped for node: prefixed targets as well.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: ea52618c-90e9-4064-bd33-79302c2b3760
📒 Files selected for processing (2)
src/env.tstest/env.test.ts
resolves #555
This PR
Summary by CodeRabbit