Skip to content

Conversation

@eastdraconis
Copy link
Contributor

@eastdraconis eastdraconis commented Oct 5, 2025

Description

I'm using .test, .setup, etc. and to ignore it, if I allow ignoreMiddleExtensions, I get an error in the app router's [...auth] etc

This PR fixes the getBasename function to properly handle dots inside brackets (e.g., [...]) when extracting the base filename. Previously, dots inside brackets were incorrectly treated as extension separators.

Problem

When processing filenames with brackets containing dots (e.g., Next.js dynamic routes like [[...slug]].tsx), the getBasename function would incorrectly identify dots inside brackets as extension delimiters.

Example:

  • Before: getBasename('[[...slug]].tsx') would incorrectly split at the first dot inside brackets
  • After: getBasename('[[...slug]].tsx') correctly returns '[[...slug]]'

Solution

Modified the getBasename function to:

  1. Track bracket depth while scanning the filename
  2. Only consider dots that are outside of bracket pairs as extension separators
  3. Return the full filename if no dots exist outside brackets

Changes

Core Changes

  • lib/utils/filename.js: Refactored getBasename to skip dots inside brackets
    • Added findDotsOutsideBrackets helper function
    • Maintains bracket depth tracking
    • Only treats dots at depth 0 as extension separators

Previously, getBasename would treat dots inside brackets as extension
separators. This commit adds logic to skip dots that appear within
bracket pairs, ensuring they are treated as part of the filename rather
than extension delimiters.
@codecov
Copy link

codecov bot commented Oct 13, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (ed88e9f) to head (a1582b1).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff            @@
##              main       #64   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           14        14           
  Lines         1083      1101   +18     
=========================================
+ Hits          1083      1101   +18     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@dukeluo dukeluo merged commit c216670 into dukeluo:main Oct 15, 2025
5 checks passed
@dukeluo
Copy link
Owner

dukeluo commented Oct 15, 2025

@eastdraconis thanks for your PR!

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.

2 participants