Skip to content

CODEOWNERS patterns crashes on paths containing square brackets [param] #42

Open
@azhukov-gyg

Description

@azhukov-gyg

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions