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

isMACAddress support for macAddressWithDots might be incorrect #1614

Closed
simonfan opened this issue Feb 23, 2021 · 1 comment · Fixed by #1616
Closed

isMACAddress support for macAddressWithDots might be incorrect #1614

simonfan opened this issue Feb 23, 2021 · 1 comment · Fixed by #1616

Comments

@simonfan
Copy link

Describe the bug
isMACAddress(str) might be using an incorrect RegExp for testing MAC address with dots. I might be wrong, have no experience at all using MAC addresses, was just browsing the code.

The pull request that introduced the support for MAC address with dots specifically intended to support 0102.0304.05ab, but the RegExp used is:

const macAddressWithDots = /^([0-9a-fA-F]{4}).([0-9a-fA-F]{4}).([0-9a-fA-F]{4})$/;
https://github.com/validatorjs/validator.js/blob/master/src/lib/isMACAddress.js#L7

Examples
The dots (.) allow for any character to work as separator
0102X0304X05ab
0102 0304 05ab
0102/0304/05ab

Additional context
Validator.js version: 13.5.1

@fedeci
Copy link
Contributor

fedeci commented Feb 23, 2021

You are right, and those regexes can be simplified. I am working on this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants