@se-oss/ip-address 1.0.0 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -724,14 +724,9 @@ var CIDR = class {
724
724
  * @throws {InvalidIPAddressError} If the CIDR string is invalid.
725
725
  */
726
726
  constructor(cidr) {
727
- const [addressPart, prefixPart] = cidr.split("/");
728
- if (!prefixPart) {
729
- throw new InvalidIPAddressError(`Invalid CIDR notation: ${cidr}`);
730
- }
731
- const prefix = parseInt(prefixPart, 10);
732
- if (isNaN(prefix)) {
733
- throw new InvalidIPAddressError(`Invalid prefix: ${prefixPart}`);
734
- }
727
+ const parts = cidr.split("/");
728
+ const addressPart = parts[0];
729
+ let prefixPart = parts[1];
735
730
  let address;
736
731
  let version;
737
732
  if (addressPart.includes(".")) {
@@ -741,6 +736,13 @@ var CIDR = class {
741
736
  address = new IPv6(addressPart);
742
737
  version = 6;
743
738
  }
739
+ if (prefixPart === void 0) {
740
+ prefixPart = String(BITS[version]);
741
+ }
742
+ const prefix = parseInt(prefixPart, 10);
743
+ if (isNaN(prefix)) {
744
+ throw new InvalidIPAddressError(`Invalid prefix: ${prefixPart}`);
745
+ }
744
746
  if (prefix < 0 || prefix > BITS[version]) {
745
747
  throw new InvalidIPAddressError(`Prefix out of range for IPv${version}: ${prefix}`);
746
748
  }
package/dist/index.js CHANGED
@@ -690,14 +690,9 @@ var CIDR = class {
690
690
  * @throws {InvalidIPAddressError} If the CIDR string is invalid.
691
691
  */
692
692
  constructor(cidr) {
693
- const [addressPart, prefixPart] = cidr.split("/");
694
- if (!prefixPart) {
695
- throw new InvalidIPAddressError(`Invalid CIDR notation: ${cidr}`);
696
- }
697
- const prefix = parseInt(prefixPart, 10);
698
- if (isNaN(prefix)) {
699
- throw new InvalidIPAddressError(`Invalid prefix: ${prefixPart}`);
700
- }
693
+ const parts = cidr.split("/");
694
+ const addressPart = parts[0];
695
+ let prefixPart = parts[1];
701
696
  let address;
702
697
  let version;
703
698
  if (addressPart.includes(".")) {
@@ -707,6 +702,13 @@ var CIDR = class {
707
702
  address = new IPv6(addressPart);
708
703
  version = 6;
709
704
  }
705
+ if (prefixPart === void 0) {
706
+ prefixPart = String(BITS[version]);
707
+ }
708
+ const prefix = parseInt(prefixPart, 10);
709
+ if (isNaN(prefix)) {
710
+ throw new InvalidIPAddressError(`Invalid prefix: ${prefixPart}`);
711
+ }
710
712
  if (prefix < 0 || prefix > BITS[version]) {
711
713
  throw new InvalidIPAddressError(`Prefix out of range for IPv${version}: ${prefix}`);
712
714
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@se-oss/ip-address",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "A modern, immutable, and zero-dependency library for working with IPv4 and IPv6 addresses in JavaScript and TypeScript.",
5
5
  "keywords": [
6
6
  "ip",