This repository has been archived by the owner on Jul 11, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: ignore invalid userToken (#802)
* fix: ignore invalid userToken * fix build error * remove unnecessary validation * console warn directly * update warning message * update test cases
- Loading branch information
Eunjae Lee
committed
Dec 4, 2020
1 parent
24f88fd
commit a2876c5
Showing
8 changed files
with
138 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,8 @@ | ||
'use strict'; | ||
|
||
module.exports = function isValidUserToken(userToken) { | ||
if (userToken === null) { | ||
return false; | ||
} | ||
return /^[a-zA-Z0-9_-]{1,64}$/.test(userToken); | ||
}; |
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
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
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,15 @@ | ||
'use strict'; | ||
|
||
var isValidUserToken = require('../../../src/utils/isValidUserToken'); | ||
|
||
test('returns true with valid user token', function() { | ||
expect(isValidUserToken('abc')).toEqual(true); | ||
expect(isValidUserToken('abc-def')).toEqual(true); | ||
expect(isValidUserToken('abc-def_ghi012')).toEqual(true); | ||
}); | ||
|
||
test('returns false with invalid user token', function() { | ||
expect(isValidUserToken(null)).toEqual(false); | ||
expect(isValidUserToken('')).toEqual(false); | ||
expect(isValidUserToken('my token')).toEqual(false); | ||
}); |