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

[Fix] isIP validator patterns for IPv4 and IPv6 RegExp formats #1632

Merged
merged 2 commits into from
Apr 17, 2021

Conversation

ognjenjevremovic
Copy link
Contributor

@ognjenjevremovic ognjenjevremovic commented Mar 19, 2021

Fixes #1626

Changes

  • Refactored the IPv4 RegExp pattern,
  • Provided a more strict IPv6 RegExp pattern (that isn't so loose and don't have false positives),
  • Extended upon the existing unit tests covering the edge cases (for previous IPv6 values that weren't recognized as valid values).

Checklist

After the changes I ensured that:

  • no stylistic or unwanted errors are present, by running npm run lint, from the root directory,
  • no tests are failing, by running npm run test from the root directory,
  • build passes with no issues, by running npm run build from the root directory.

Done

  • PR contains only changes related; no stray files, etc.
  • README updated (where applicable)
  • Added/updated unit tests for this change
  • Included links to related issues/PRs
  • Ensured the 100% code coverage (of the changes / validator)

Ognjen Jevremovic added 2 commits March 19, 2021 14:24
Provide a more strict regular expression patterns for ipv4 and ipv6
formats.

✅ Closes: validatorjs#1626
Extend upon existing IP validator unit test, valid examples. Provide
IPv6 test addresses including `%`.

✅ Closes: validatorjs#1626
@ognjenjevremovic ognjenjevremovic changed the title [Fix] isIP validator patterns for IPv4 and IPv6 RegExp formats [Fix] isIP validator patterns for IPv4 and IPv6 RegExp formats Mar 19, 2021
@codecov
Copy link

codecov bot commented Mar 19, 2021

Codecov Report

Merging #1632 (89f77ae) into master (63b6162) will not change coverage.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff            @@
##            master     #1632   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files          100       100           
  Lines         1843      1811   -32     
=========================================
- Hits          1843      1811   -32     
Impacted Files Coverage Δ
src/lib/isIP.js 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 63b6162...89f77ae. Read the comment docs.

Copy link
Member

@tux-tn tux-tn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your PR @ognjenjevremovic 🎉 !
You managed to include many previously unhandled cases for IPv6 and your approach is more simple and clean than the old implementation of isIP .
Really great job!

@tux-tn tux-tn added ready-to-land For PRs that are reviewed and ready to be landed 🎉 first-pr labels Mar 19, 2021
Copy link
Member

@profnandaa profnandaa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks for your contrib and welcome to the project! 🎉

@profnandaa profnandaa merged commit 2ef84e4 into validatorjs:master Apr 17, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🎉 first-pr ready-to-land For PRs that are reviewed and ready to be landed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants