fix: try extensions for dotted basenames#155
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughUpdated 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
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 |
Reviewer's guide (collapsed on small PRs)Reviewer's GuideExtends the send() middleware's extension resolution logic to try configured extensions whenever the requested path doesn't exist (including dotted basenames), and adds a regression test plus fixture for this behavior. Sequence diagram for updated send extension resolutionsequenceDiagram
participant Client
participant SendMiddleware as send
participant FileSystem as isPathExists
Client->>SendMiddleware: send(req, res, next)
SendMiddleware->>FileSystem: isPathExists(filePath)
FileSystem-->>SendMiddleware: exists / not exists
alt [filePath does not exist]
SendMiddleware->>SendMiddleware: for ext in extensions
SendMiddleware->>FileSystem: isPathExists(filePath + ext)
FileSystem-->>SendMiddleware: exists / not exists
else [filePath exists]
SendMiddleware->>SendMiddleware: skip extension fallback
end
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
test/index.test.ts (1)
693-707: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueTest correctly covers the dotted-basename fallback; minor grammar nitpick.
The test properly exercises the new behavior — requesting
hello.world(which doesn't exist) withextensions: ['txt']should resolve tohello.world.txt. The assertion matches the fixture content.Minor: the describe text uses "sufficed" where "suffixed" is intended.
📝 Grammar fix
- describe('when trying to get a file without extension with matching .extensions sufficed with a dot in the basename', () => { + describe('when trying to get a file without extension with matching .extensions suffixed with a dot in the basename', () => {🤖 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/index.test.ts` around lines 693 - 707, Update the describe text in the test covering the dotted-basename extension fallback to replace “sufficed” with “suffixed”; leave the test setup and assertions unchanged.
🤖 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.
Inline comments:
In `@src/send.ts`:
- Line 82: Update isPathExists in send.utils.ts to return false only when
fs.access fails with ENOENT, and re-throw all other errors such as EACCES.
Preserve the existing extension-check flow in send.ts for genuinely missing
paths.
---
Nitpick comments:
In `@test/index.test.ts`:
- Around line 693-707: Update the describe text in the test covering the
dotted-basename extension fallback to replace “sufficed” with “suffixed”; leave
the test setup and assertions unchanged.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 8623f851-3f11-44b3-9e85-965a01292d1f
📒 Files selected for processing (3)
src/send.tstest/fixtures/hello.world.txttest/index.test.ts
Summary
extensionswhen the exact requested path does not exist, including dotted basenames such ashello.worldVerification
npx jest test/index.test.ts --runInBand --testNamePattern='extensions option'npm testnpm run lintnpm run buildgit diff --checkRefs #143.
Summary by Sourcery
Handle extension fallback for files whose basenames contain dots and add regression coverage for this behavior.
Bug Fixes:
Tests:
Summary by CodeRabbit
filePath + extnow depends on whether the original path exists.ENOENT, while other access errors are surfaced.extensionsbehavior for filenames containing dots (e.g.,hello.world) and verified successful responses.