Skip to content

Commit

Permalink
Merge pull request #17 from xiaojian-hong/master
Browse files Browse the repository at this point in the history
Supports Chinese file name
  • Loading branch information
yumauri authored Sep 5, 2020
2 parents f387ee8 + 84cc655 commit 8ab8309
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/internal/source-checkers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@ 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 = /^[\w\s\(\),-]+\.[A-Za-z0-9]+$/
/* tslint:disable:no-empty-character-class */
const fileNameRE = /^[\p{L}\w\s\(\),-]+\.[A-Za-z0-9]+$/u
const MIN_FILE_NAME_LENGTH = 3
const MAX_FILE_NAME_LENGTH = 50
export const isFileName = (x: Source | undefined | null) =>
Expand Down
2 changes: 2 additions & 0 deletions test/internal/source-checkers.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ test('Test `isFileName` function', function () {
expect(isFileName('index.html')).toBe(true) // <-
expect(isFileName('test.md')).toBe(true) // <-
expect(isFileName('image.gif')).toBe(true) // <-
expect(isFileName('中文.gif')).toBe(true) // <-
expect(isFileName(url)).toBe(false)
expect(isFileName(array)).toBe(false)
expect(isFileName(map)).toBe(false)
Expand All @@ -56,6 +57,7 @@ test('Test `isFileName` function', function () {
expect(isFileName(buffer)).toBe(false)
expect(isFileName(generator())).toBe(false)
expect(isFileName(iterator)).toBe(false)
expect(isFileName('中文')).toBe(false)
})

test('Test `isFileUri` function', function () {
Expand Down

0 comments on commit 8ab8309

Please sign in to comment.