codeowners icon indicating copy to clipboard operation
codeowners copied to clipboard

CODEOWNERS patterns crashes on paths containing square brackets [param]

Open azhukov-gyg opened this issue 8 months ago • 0 comments

Problem CODEOWNERS patterns fail to match file paths containing square brackets, which are commonly used in modern web frameworks (Next.js, Nuxt.js) for dynamic routes.

Minimal Reproduction

Example 1: File with square brackets

project/
├── pages/
│   ├── index.js
│   └── users/
│       └── [userId].js
└── CODEOWNERS

CODEOWNERS file:

/pages/users/[userId].js @team

Expected Behavior:

The file /pages/users/[userId].js should be owned by @team

Error Produced:

$ codeowners
line 1: unexpected character '[' at position 13

Example 2: Directory with square brackets:

project/
├── pages/
│   ├── index.js
│   └── [userId]/
│       ├── index.js
│       └── details.js
└── CODEOWNERS

CODEOWNERS file:

pages/[userId]/index.js @team1
pages/[userId]/details.js @team2

Expected Behavior: The file pages/[userId]/index.js should be owned by @team1 The file pages/[userId]/details.js should be owned by @team2

Error Produced:

$ codeowners
line 1: unexpected character '[' at position 7

azhukov-gyg avatar Apr 29 '25 06:04 azhukov-gyg