Skip to content

Commit

Permalink
Merge pull request #8 from bmonty/bmonty/bug-fix/issue-7
Browse files Browse the repository at this point in the history
Bmonty/bug fix/issue 7
  • Loading branch information
tylerdmace committed Mar 14, 2015
2 parents 3de8173 + 2eaceda commit 55dca54
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
subnetter.sublime-workspace
subnetter.sublime-project
2 changes: 1 addition & 1 deletion subnetter.js
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@
var sub = Subnetter.addressToDecimal(subnet_id);
var mask = Subnetter.addressToDecimal(netmask);

if ((addr & mask) === sub){
if (((addr & mask) >>> 0) === sub){
return 1;
}
else{
Expand Down
6 changes: 6 additions & 0 deletions test/test.subnetter.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,10 @@ describe('SubnetterJS', function() {
expect(Subnetter.getNetwork('192.168.1.0', '255.255.255.0')).to.equal('192.168.1.0');
});

it('can check if an IP is part of a subnet', function() {
expect(Subnetter.checkIPInSubnet('192.168.1.1', '192.168.1.0', '255.255.255.0'), 1);
expect(Subnetter.checkIPInSubnet('192.168.204.201', '192.168.204.0', '255.255.255.0'), 1);
expect(Subnetter.checkIPInSubnet('192.168.203.100', '192.168.204.0', '255.255.255.0') ,0);
})

});

0 comments on commit 55dca54

Please sign in to comment.