File tree Expand file tree Collapse file tree 2 files changed +3
-2
lines changed
Expand file tree Collapse file tree 2 files changed +3
-2
lines changed Original file line number Diff line number Diff line change @@ -17,7 +17,8 @@ export class IPv4 extends IPAddress {
1717
1818 public constructor ( value : number | bigint ) {
1919 const int = BigInt ( value ) ;
20- if ( int < 0n || int > 0xFFFFFFFFn ) throw new TypeError ( "Expected 32-bit unsigned integer, got " + int . constructor . name + " " + int . toString ( 10 ) ) ;
20+ if ( int < 0n || int > ( 1n << BigInt ( IPv4 . bitLength ) ) - 1n )
21+ throw new TypeError ( "Expected 32-bit unsigned integer, got " + int . constructor . name + " " + int . toString ( 10 ) ) ;
2122 super ( int ) ;
2223 }
2324
Original file line number Diff line number Diff line change @@ -10,7 +10,7 @@ export class IPv6 extends IPAddress {
1010 * Create new IPv6 address instance
1111 */
1212 public constructor ( value : bigint ) {
13- if ( value < 0n || value > 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFn )
13+ if ( value < 0n || value > ( ( 1n << BigInt ( IPv6 . bitLength ) ) - 1n ) )
1414 throw new TypeError ( "Expected 128-bit unsigned integer, got " + value . constructor . name + " 0x" + value . toString ( 16 ) ) ;
1515 super ( value ) ;
1616 }
You can’t perform that action at this time.
0 commit comments