-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into feat/Jamaica-addition
- Loading branch information
Showing
22 changed files
with
1,600 additions
and
101 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,3 +10,4 @@ yarn.lock | |
/index.js | ||
validator.js | ||
validator.min.js | ||
|
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 |
---|---|---|
|
@@ -77,7 +77,7 @@ export default function isEmail(str, options) { | |
// eg. myname <[email protected]> | ||
// the display name is `myname` instead of `myname `, so need to trim the last space | ||
if (display_name.endsWith(' ')) { | ||
display_name = display_name.substr(0, display_name.length - 1); | ||
display_name = display_name.slice(0, -1); | ||
} | ||
|
||
if (!validateDisplayName(display_name)) { | ||
|
@@ -144,7 +144,7 @@ export default function isEmail(str, options) { | |
return false; | ||
} | ||
|
||
let noBracketdomain = domain.substr(1, domain.length - 2); | ||
let noBracketdomain = domain.slice(1, -1); | ||
|
||
if (noBracketdomain.length === 0 || !isIP(noBracketdomain)) { | ||
return false; | ||
|
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,26 @@ | ||
import assertString from './util/assertString'; | ||
|
||
export default function isLuhnValid(str) { | ||
assertString(str); | ||
const sanitized = str.replace(/[- ]+/g, ''); | ||
let sum = 0; | ||
let digit; | ||
let tmpNum; | ||
let shouldDouble; | ||
for (let i = sanitized.length - 1; i >= 0; i--) { | ||
digit = sanitized.substring(i, (i + 1)); | ||
tmpNum = parseInt(digit, 10); | ||
if (shouldDouble) { | ||
tmpNum *= 2; | ||
if (tmpNum >= 10) { | ||
sum += ((tmpNum % 10) + 1); | ||
} else { | ||
sum += tmpNum; | ||
} | ||
} else { | ||
sum += tmpNum; | ||
} | ||
shouldDouble = !shouldDouble; | ||
} | ||
return !!((sum % 10) === 0 ? sanitized : false); | ||
} |
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 |
---|---|---|
@@ -1,8 +1,13 @@ | ||
import assertString from './util/assertString'; | ||
|
||
const magnetURI = /^magnet:\?xt(?:\.1)?=urn:(?:aich|bitprint|btih|ed2k|ed2khash|kzhash|md5|sha1|tree:tiger):[a-z0-9]{32}(?:[a-z0-9]{8})?($|&)/i; | ||
const magnetURIComponent = /(?:^magnet:\?|[^?&]&)xt(?:\.1)?=urn:(?:(?:aich|bitprint|btih|ed2k|ed2khash|kzhash|md5|sha1|tree:tiger):[a-z0-9]{32}(?:[a-z0-9]{8})?|btmh:1220[a-z0-9]{64})(?:$|&)/i; | ||
|
||
export default function isMagnetURI(url) { | ||
assertString(url); | ||
return magnetURI.test(url.trim()); | ||
|
||
if (url.indexOf('magnet:?') !== 0) { | ||
return false; | ||
} | ||
|
||
return magnetURIComponent.test(url); | ||
} |
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
Oops, something went wrong.