Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions src/lib/ownership/OwnershipEngine.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,17 @@ describe('OwnershipEngine', () => {
expect(() => OwnershipEngine.FromCodeownersFile('some/codeowners/file'))
.toThrowError(expectedError);
});

it('ignore trailing whitespace', () => {
// Arrange
const codeowners = 'some/file @org/owners ';

readFileSyncMock.mockReturnValue(Buffer.from(codeowners));

// Assert
expect(() => OwnershipEngine.FromCodeownersFile('some/codeowners/file'))
.not.toThrow();
});
});

describe.each<any>(patterns)('$name: "$pattern"', ({ name, pattern, paths }) => {
Expand Down
2 changes: 1 addition & 1 deletion src/lib/ownership/OwnershipEngine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export class OwnershipEngine {

const createMatcherCodeownersRule = (rule: string): FileOwnershipMatcher => {
// Split apart on spaces
const parts = rule.split(/\s+/);
const parts = rule.split(/\s+/).filter(Boolean);

Choose a reason for hiding this comment

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

I would just use .trim(), makes it more readable


// The first part is expected to be the path
const path = parts[0];
Expand Down