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

isValid() returns false for undefined string #32

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ipaddr.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/ipaddr.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/ipaddr.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ ipaddr.IPv4.isValid = (string) ->
ipaddr.IPv6.isValid = (string) ->
# Since IPv6.isValid is always called first, this shortcut
# provides a substantial performance gain.
if string.indexOf(":") == -1
if not string or string.indexOf(":") == -1
return false

try
Expand Down
1 change: 1 addition & 0 deletions test/ipaddr.test.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ module.exports =
test.equal(ipaddr.IPv6.isValid('2001:db8::F53A::1'), false)
test.equal(ipaddr.IPv6.isValid('fe80::wtf'), false)
test.equal(ipaddr.IPv6.isValid('2002::2:'), false)
test.equal(ipaddr.IPv6.isValid(undefined), false)
test.done()

'parses IPv6 in different formats': (test) ->
Expand Down