Skip to content

Fix #11: Add case-sensitive file checking for internal links - #16

Merged
fulldecent merged 1 commit into
mainfrom
fix-issue-11-case-sensitive-internal-links
Dec 4, 2025
Merged

fulldecent merged 1 commit into
mainfrom
fix-issue-11-case-sensitive-internal-links

Conversation

@fulldecent

Copy link
Copy Markdown
Owner

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:

  • Reading the actual directory contents with fs.readdirSync()
  • Comparing the requested filename with the exact filenames in the directory listing
  • Only returning true if the case matches exactly

Changes

  • InternalLinksRule.ts: Modified doesFileExist() to check case sensitivity using directory listing comparison
  • Documentation: Added explanation of case-sensitive checking behavior with examples
  • Test: Added InternalLinksRule-violation-case-sensitive.html that verifies No-Errors.html (wrong case) fails even though no-errors.html (correct case) exists
  • All 23 tests passing

Example

File exists: no-errors.html

  • Works: href="no-errors.html" (correct case)
  • Fails: href="No-Errors.html" (wrong case detected)

This ensures developers catch case mismatches during development on macOS before deploying to Linux production servers.

- 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.
Copilot AI review requested due to automatic review settings December 4, 2025 20:28

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@fulldecent
fulldecent merged commit 5f259a6 into main Dec 4, 2025
7 of 10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Internal links: check case sensitive

2 participants