Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add failing tests for incorrect handling of single quotes w/ brace expansion #479

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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
Empty file added fixtures2/fifth's/fileA.md
Empty file.
Empty file added fixtures2/fifth's/fileB.md
Empty file.
Empty file added fixtures2/fourth/file'sA.md
Empty file.
Empty file added fixtures2/fourth/file'sB.md
Empty file.
105 changes: 105 additions & 0 deletions src/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,111 @@

assert.deepStrictEqual(actual, expected);
});

it('should return entries with UN-escaped hanging single-quote in filename', () => {
const expected: EntryItem[] = [
"fixtures2/fourth/file'sA.md",
"fixtures2/fourth/file'sB.md",
];

const actual = fg.globSync(["fixtures2/fourth/file's*.md"]);

actual.sort((a, b) => a.localeCompare(b));

assert.deepStrictEqual(actual, expected);
});

it('should return entries with escaped hanging single-quote in filename', () => {
const expected: EntryItem[] = [
"fixtures2/fourth/file'sA.md",
"fixtures2/fourth/file'sB.md",
];

const actual = fg.globSync([String.raw`fixtures2/fourth/file\'s*.md`]);

actual.sort((a, b) => a.localeCompare(b));

assert.deepStrictEqual(actual, expected);
});


Check failure on line 85 in src/index.spec.ts

View workflow job for this annotation

GitHub Actions / Node.js 18.18.0 on ubuntu-latest

More than 1 blank line not allowed

Check failure on line 85 in src/index.spec.ts

View workflow job for this annotation

GitHub Actions / Node.js 18.18.0 on windows-latest

More than 1 blank line not allowed

Check failure on line 85 in src/index.spec.ts

View workflow job for this annotation

GitHub Actions / Node.js 18.18.0 on macos-latest

More than 1 blank line not allowed

Check failure on line 85 in src/index.spec.ts

View workflow job for this annotation

GitHub Actions / Node.js 18 on macos-latest

More than 1 blank line not allowed

Check failure on line 85 in src/index.spec.ts

View workflow job for this annotation

GitHub Actions / Node.js 18 on ubuntu-latest

More than 1 blank line not allowed

Check failure on line 85 in src/index.spec.ts

View workflow job for this annotation

GitHub Actions / Node.js 18 on windows-latest

More than 1 blank line not allowed

Check failure on line 85 in src/index.spec.ts

View workflow job for this annotation

GitHub Actions / Node.js 20 on macos-latest

More than 1 blank line not allowed

Check failure on line 85 in src/index.spec.ts

View workflow job for this annotation

GitHub Actions / Node.js 20 on windows-latest

More than 1 blank line not allowed

Check failure on line 85 in src/index.spec.ts

View workflow job for this annotation

GitHub Actions / Node.js 20 on ubuntu-latest

More than 1 blank line not allowed

Check failure on line 85 in src/index.spec.ts

View workflow job for this annotation

GitHub Actions / Node.js 22 on macos-latest

More than 1 blank line not allowed

Check failure on line 85 in src/index.spec.ts

View workflow job for this annotation

GitHub Actions / Node.js 22 on ubuntu-latest

More than 1 blank line not allowed

Check failure on line 85 in src/index.spec.ts

View workflow job for this annotation

GitHub Actions / Node.js 22 on windows-latest

More than 1 blank line not allowed
it('should return entries with UN-escaped hanging single-quote in filename + brace expansion', () => {
const expected: EntryItem[] = [
"fixtures2/fourth/file'sA.md",
"fixtures2/fourth/file'sB.md",
];

const actual = fg.globSync([String.raw`fixtures2/fourth/file's{A,B}.md`]);

actual.sort((a, b) => a.localeCompare(b));

assert.deepStrictEqual(actual, expected);
});

it('should return entries with escaped hanging single-quote in filename + brace expansion', () => {
const expected: EntryItem[] = [
"fixtures2/fourth/file'sA.md",
"fixtures2/fourth/file'sB.md",
];

const actual = fg.globSync([String.raw`fixtures2/fourth/file\'s{A,B}.md`]);

actual.sort((a, b) => a.localeCompare(b));

assert.deepStrictEqual(actual, expected);
});

it('should return entries with UN-escaped hanging single-quote in PARENT directory', () => {
const expected: EntryItem[] = [
"fixtures2/fifth's/fileA.md",
"fixtures2/fifth's/fileB.md",
];

const actual = fg.globSync([String.raw`fixtures2/fifth's/file*.md`]);

actual.sort((a, b) => a.localeCompare(b));

assert.deepStrictEqual(actual, expected);
});

it('should return entries with escaped hanging single-quote in PARENT directory', () => {
const expected: EntryItem[] = [
"fixtures2/fifth's/fileA.md",
"fixtures2/fifth's/fileB.md",
];

const actual = fg.globSync([String.raw`fixtures2/second\'s/file*.md`]);

actual.sort((a, b) => a.localeCompare(b));

assert.deepStrictEqual(actual, expected);
});

it('should return entries with UN-escaped hanging single-quote in PARENT directory + brace expansion', () => {
const expected: EntryItem[] = [
"fixtures2/fifth's/fileA.md",
"fixtures2/fifth's/fileB.md",
];

const actual = fg.globSync([String.raw`fixtures2/second's/file{A, B}.md`]);

actual.sort((a, b) => a.localeCompare(b));

assert.deepStrictEqual(actual, expected);
});

it('should return entries with escaped hanging single-quote in PARENT directory + brace expansion', () => {
const expected: EntryItem[] = [
"fixtures2/fifth's/fileA.md",
"fixtures2/fifth's/fileB.md",
];

const actual = fg.globSync([String.raw`fixtures2/second\'s/file{A, B}.md`]);

actual.sort((a, b) => a.localeCompare(b));

assert.deepStrictEqual(actual, expected);
});
});

describe('.sync', () => {
Expand Down
8 changes: 8 additions & 0 deletions src/utils/pattern.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,14 @@
assert.ok(util.isDynamicPattern('{2..10..2}'));
});

it('should return true for patterns that include single quotes and brace expansions symbols', () => {
assert.ok(util.isDynamicPattern(String.raw`chilis/menu's.{jpg,png,pdf}`));
assert.ok(util.isDynamicPattern(String.raw`chilis/menu\'s.{jpg,png,pdf}`));
assert.ok(util.isDynamicPattern(String.raw`chili's/menus.{jpg,png,pdf}`));
assert.ok(util.isDynamicPattern(String.raw`chili\'s/menus.{jpg,png,pdf}`));
});


Check failure on line 106 in src/utils/pattern.spec.ts

View workflow job for this annotation

GitHub Actions / Node.js 18.18.0 on ubuntu-latest

More than 1 blank line not allowed

Check failure on line 106 in src/utils/pattern.spec.ts

View workflow job for this annotation

GitHub Actions / Node.js 18.18.0 on windows-latest

More than 1 blank line not allowed

Check failure on line 106 in src/utils/pattern.spec.ts

View workflow job for this annotation

GitHub Actions / Node.js 18.18.0 on macos-latest

More than 1 blank line not allowed

Check failure on line 106 in src/utils/pattern.spec.ts

View workflow job for this annotation

GitHub Actions / Node.js 18 on macos-latest

More than 1 blank line not allowed

Check failure on line 106 in src/utils/pattern.spec.ts

View workflow job for this annotation

GitHub Actions / Node.js 18 on ubuntu-latest

More than 1 blank line not allowed

Check failure on line 106 in src/utils/pattern.spec.ts

View workflow job for this annotation

GitHub Actions / Node.js 18 on windows-latest

More than 1 blank line not allowed

Check failure on line 106 in src/utils/pattern.spec.ts

View workflow job for this annotation

GitHub Actions / Node.js 20 on macos-latest

More than 1 blank line not allowed

Check failure on line 106 in src/utils/pattern.spec.ts

View workflow job for this annotation

GitHub Actions / Node.js 20 on windows-latest

More than 1 blank line not allowed

Check failure on line 106 in src/utils/pattern.spec.ts

View workflow job for this annotation

GitHub Actions / Node.js 20 on ubuntu-latest

More than 1 blank line not allowed

Check failure on line 106 in src/utils/pattern.spec.ts

View workflow job for this annotation

GitHub Actions / Node.js 22 on macos-latest

More than 1 blank line not allowed

Check failure on line 106 in src/utils/pattern.spec.ts

View workflow job for this annotation

GitHub Actions / Node.js 22 on ubuntu-latest

More than 1 blank line not allowed

Check failure on line 106 in src/utils/pattern.spec.ts

View workflow job for this annotation

GitHub Actions / Node.js 22 on windows-latest

More than 1 blank line not allowed
it('should return false for brace extension when the `braceExpansion` option is disabled', () => {
assert.ok(!util.isDynamicPattern('{,}', { braceExpansion: false }));
assert.ok(!util.isDynamicPattern('{a,}', { braceExpansion: false }));
Expand Down
Loading