-
-
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.
- Loading branch information
Showing
18 changed files
with
511 additions
and
359 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 |
---|---|---|
@@ -0,0 +1,33 @@ | ||
name: CI | ||
on: | ||
push: | ||
branches: [master] | ||
pull_request: | ||
branches: [master] | ||
jobs: | ||
test: | ||
runs-on: ubuntu-20.04 | ||
strategy: | ||
matrix: | ||
node-version: [14, 12, 10, 8, 6] | ||
name: Run tests on Node.js ${{ matrix.node-version }} | ||
steps: | ||
- name: Setup Node.js ${{ matrix.node-version }} | ||
uses: actions/setup-node@v2-beta | ||
with: | ||
node-version: ${{ matrix.node-version }} | ||
check-latest: true | ||
- name: Checkout repository | ||
uses: actions/checkout@v2 | ||
- name: Install dependencies | ||
run: npm install | ||
- name: Run tests | ||
run: npm test | ||
- if: matrix.node-version == 14 | ||
name: Generate coverage file | ||
run: npm run test:ci > coverage.lcov | ||
- if: matrix.node-version == 14 | ||
name: Send coverage info to Codecov | ||
uses: codecov/codecov-action@v1 | ||
with: | ||
file: ./coverage.lcov |
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,24 @@ | ||
name: NPM Publish | ||
on: | ||
release: | ||
types: [created] | ||
jobs: | ||
publish: | ||
runs-on: ubuntu-20.04 | ||
steps: | ||
- name: Setup Node.js 14 | ||
uses: actions/setup-node@v2-beta | ||
with: | ||
node-version: 14 | ||
check-latest: true | ||
registry-url: https://registry.npmjs.org/ | ||
- name: Checkout Repository | ||
uses: actions/checkout@v2 | ||
- name: Install Dependencies | ||
run: npm install | ||
- name: Run Tests | ||
run: npm test | ||
- name: Publish Package to NPM Registry | ||
run: npm publish | ||
env: | ||
NODE_AUTH_TOKEN: ${{secrets.NPM_SECRET}} |
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 |
---|---|---|
|
@@ -7,6 +7,6 @@ package-lock.json | |
yarn.lock | ||
/es | ||
/lib | ||
/index.js | ||
validator.js | ||
validator.min.js | ||
index.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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,9 +5,5 @@ | |
], | ||
"include": [ | ||
"src/**/*.js" | ||
], | ||
"exclude": [ | ||
"validator.js", | ||
"lib/**/*.js" | ||
] | ||
} |
This file was deleted.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
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,7 +1,7 @@ | ||
{ | ||
"name": "validator-js", | ||
"main": "validator.js", | ||
"homepage": "https://github.com/chriso/validator.js", | ||
"homepage": "https://github.com/validatorjs/validator.js", | ||
"authors": [ | ||
"Chris O'Hara <[email protected]>" | ||
], | ||
|
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 |
---|---|---|
|
@@ -3,7 +3,7 @@ | |
"description": "String validation and sanitization", | ||
"version": "13.5.1", | ||
"sideEffects": false, | ||
"homepage": "https://github.com/chriso/validator.js", | ||
"homepage": "https://github.com/validatorjs/validator.js", | ||
"files": [ | ||
"index.js", | ||
"es", | ||
|
@@ -25,18 +25,15 @@ | |
], | ||
"author": "Chris O'Hara <[email protected]>", | ||
"contributors": [ | ||
{ | ||
"name": "Anthony Nandaa", | ||
"url": "https://github.com/profnandaa" | ||
} | ||
"Anthony Nandaa (https://github.com/profnandaa)" | ||
], | ||
"main": "index.js", | ||
"bugs": { | ||
"url": "https://github.com/chriso/validator.js/issues" | ||
"url": "https://github.com/validatorjs/validator.js/issues" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/chriso/validator.js.git" | ||
"url": "git+https://github.com/validatorjs/validator.js.git" | ||
}, | ||
"devDependencies": { | ||
"@babel/cli": "^7.0.0", | ||
|
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 |
---|---|---|
@@ -1,19 +1,18 @@ | ||
import assertString from './util/assertString'; | ||
|
||
const macAddress = /^([0-9a-fA-F][0-9a-fA-F]:){5}([0-9a-fA-F][0-9a-fA-F])$/; | ||
const macAddressNoColons = /^([0-9a-fA-F]){12}$/; | ||
const macAddressWithHyphen = /^([0-9a-fA-F][0-9a-fA-F]-){5}([0-9a-fA-F][0-9a-fA-F])$/; | ||
const macAddressWithSpaces = /^([0-9a-fA-F][0-9a-fA-F]\s){5}([0-9a-fA-F][0-9a-fA-F])$/; | ||
const macAddressWithDots = /^([0-9a-fA-F]{4}).([0-9a-fA-F]{4}).([0-9a-fA-F]{4})$/; | ||
const macAddress = /^(?:[0-9a-fA-F]{2}([-:\s]))([0-9a-fA-F]{2}\1){4}([0-9a-fA-F]{2})$/; | ||
const macAddressNoSeparators = /^([0-9a-fA-F]){12}$/; | ||
const macAddressWithDots = /^([0-9a-fA-F]{4}\.){2}([0-9a-fA-F]{4})$/; | ||
|
||
export default function isMACAddress(str, options) { | ||
assertString(str); | ||
if (options && options.no_colons) { | ||
return macAddressNoColons.test(str); | ||
/** | ||
* @deprecated `no_colons` TODO: remove it in the next major | ||
*/ | ||
if (options && (options.no_colons || options.no_separators)) { | ||
return macAddressNoSeparators.test(str); | ||
} | ||
|
||
return macAddress.test(str) | ||
|| macAddressWithHyphen.test(str) | ||
|| macAddressWithSpaces.test(str) | ||
|| macAddressWithDots.test(str); | ||
} |
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
Oops, something went wrong.