Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: disallow windows reserved filenames
- Loading branch information
Showing
3 changed files
with
52 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import { isBlacklisted } from "../blacklist"; | ||
|
||
it("should disallow CON", () => { | ||
expect.assertions(2); | ||
expect(isBlacklisted("CON")).toBeTruthy(); | ||
expect(isBlacklisted("foo/CON")).toBeTruthy(); | ||
}); | ||
|
||
it("should disallow PRN", () => { | ||
expect.assertions(2); | ||
expect(isBlacklisted("PRN")).toBeTruthy(); | ||
expect(isBlacklisted("foo/PRN")).toBeTruthy(); | ||
}); | ||
|
||
it("should disallow AUX", () => { | ||
expect.assertions(2); | ||
expect(isBlacklisted("AUX")).toBeTruthy(); | ||
expect(isBlacklisted("foo/AUX")).toBeTruthy(); | ||
}); | ||
|
||
it("should disallow NUL", () => { | ||
expect.assertions(2); | ||
expect(isBlacklisted("NUL")).toBeTruthy(); | ||
expect(isBlacklisted("foo/NUL")).toBeTruthy(); | ||
}); | ||
|
||
it("should disallow COM", () => { | ||
expect.assertions(2); | ||
expect(isBlacklisted("COM1")).toBeTruthy(); | ||
expect(isBlacklisted("foo/COM9")).toBeTruthy(); | ||
}); | ||
|
||
it("should disallow LPT", () => { | ||
expect.assertions(2); | ||
expect(isBlacklisted("LPT1")).toBeTruthy(); | ||
expect(isBlacklisted("foo/LPT9")).toBeTruthy(); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { filename } from "./helpers"; | ||
|
||
/* reserved filenames on windows */ | ||
const regexp: RegExp[] = [ | ||
filename("CON"), | ||
filename("PRN"), | ||
filename("AUX"), | ||
filename("NUL"), | ||
/(^|\/)COM\d/, | ||
/(^|\/)LPT\d/, | ||
]; | ||
|
||
export default regexp; |