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

Supports Chinese file name #17

Merged
merged 4 commits into from
Sep 5, 2020
Merged
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
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