Fix #11: Add case-sensitive file checking for internal links - #16
Merged
Merged
Conversation
- Updated InternalLinksRule to perform case-sensitive file matching - Uses directory listing comparison to verify exact filename case - Prevents issues where macOS treats /abc.webp and /AbC.webp as same file - Ensures code works correctly on Linux servers where case matters - Added test fixture verifying wrong case is detected as broken link - Updated documentation explaining case-sensitive behavior - All 23 tests passing This catches case mismatches during development on macOS that would cause 404s on Linux production servers.
There was a problem hiding this comment.
Pull request overview
This PR adds case-sensitive file checking to the InternalLinksRule to catch file case mismatches on case-insensitive filesystems (like macOS default) before they cause 404 errors on case-sensitive production servers (Linux).
Key changes:
- Modified
doesFileExist()to verify exact filename case using directory listing comparison - Added comprehensive test coverage with a dedicated fixture file testing both correct and incorrect case scenarios
- Updated documentation with clear examples explaining the case-sensitive behavior
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| src/rules/InternalLinksRule.ts | Enhanced doesFileExist() method to perform case-sensitive filename validation by comparing requested basename against actual directory contents using fs.readdirSync() |
| tests/fixtures/InternalLinksRule-violation-case-sensitive.html | New test fixture demonstrating case-sensitive validation with two links: one with correct case (passes) and one with wrong case (fails) |
| tests/fixtures/required-reports.json | Added expected validation error for the case-sensitive test fixture, specifying the error should occur on line 14 for the wrong-case link |
| README.md | Enhanced documentation with explanation of case-sensitive checking behavior and added examples showing both failing (wrong case) and passing (correct case) links |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
Closes #11
Problem
On macOS (case-insensitive filesystem by default), a link to /abc.webp would work even if the actual file is /AbC.webp. However, this breaks on Linux servers where case matters, causing 404 errors in production.
Solution
Updated InternalLinksRule to perform case-sensitive file checking even on case-insensitive filesystems by:
Changes
Example
File exists: no-errors.html
This ensures developers catch case mismatches during development on macOS before deploying to Linux production servers.