Skip to content

Commit

Permalink
Fix #38: allow filenames with dots
Browse files Browse the repository at this point in the history
  • Loading branch information
yumauri committed Dec 27, 2021
1 parent fc775e6 commit 62ce10c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/internal/source-checkers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ export const isIterable = (
* Check, if given argument is simple string, and presumably is is just file name
* I hope no one will wants to use filename longer than 50 symbols :)
*/
const fileNameRE = /^[\p{L}\w\s\(\),-]+\.[A-Za-z0-9]+$/u // tslint:disable-line no-empty-character-class
const fileNameRE = /^[\p{L}\w\s\(\).,-]+\.[A-Za-z0-9]+$/u // tslint:disable-line no-empty-character-class
const MIN_FILE_NAME_LENGTH = 3
const MAX_FILE_NAME_LENGTH = 50
export const isFileName = (x: Source | undefined | null) =>
Expand Down
4 changes: 4 additions & 0 deletions test/internal/source-checkers.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ test('Test `isFileName` function', function () {
expect(isFileName('image.gif')).toBe(true) // <-
expect(isFileName('中文.gif')).toBe(true) // <-
expect(isFileName('عربي.jpg')).toBe(true) // <-
expect(isFileName('Screenshot 2021-12-24 at 09.16.20.png')).toBe(true) // <-
expect(isFileName('.test.png')).toBe(true) // <-
expect(isFileName('.png')).toBe(false)
expect(isFileName('🙀.png')).toBe(false)
expect(isFileName(url)).toBe(false)
expect(isFileName(array)).toBe(false)
expect(isFileName(map)).toBe(false)
Expand Down

0 comments on commit 62ce10c

Please sign in to comment.