Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: exporting at the end of files
Browse files Browse the repository at this point in the history
GrandinLuc committed Jan 29, 2025
1 parent 0aec076 commit f9a8ed9
Showing 2 changed files with 7 additions and 3 deletions.
6 changes: 4 additions & 2 deletions packages/core/src/utils/const/ip.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
export const IP_CONSTANTS = {
const IP_CONSTANTS = {
IPV4_LENGTH: 4,
IPV6_LENGTH: 16,
MAX_PORT: 65535,
IPV6_SEGMENTS: 8
} as const;

export const IP_REGEX = {
const IP_REGEX = {
IPV4_PORT: /^(?:\d{1,3}\.){3}\d{1,3}:\d{1,5}$/,
IPV6_PORT: /^\[(([0-9a-fA-F]{0,4}:){1,7}[0-9a-fA-F]{0,4})\]:(\d{1,5})$/,
IPV6_WITH_PORT: /^\[(.*)\]:(\d+)$/,
HEX_SEGMENT: /^[0-9a-fA-F]{1,4}$/
} as const;

export { IP_CONSTANTS, IP_REGEX };
4 changes: 3 additions & 1 deletion packages/core/src/utils/ip/ip.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { InvalidDataType } from '@vechain/sdk-errors';
import { IP_CONSTANTS, IP_REGEX } from '../const/ip';

export function expandIPv6(compressedIP: string): string {
function expandIPv6(compressedIP: string): string {
const matches = IP_REGEX.IPV6_WITH_PORT.exec(compressedIP);
if (matches === null) {
throw new InvalidDataType(
@@ -96,3 +96,5 @@ function fillWithZeros(segments: string[], addZerosToStart: boolean): string[] {
const zeros = Array(zerosNeeded).fill('0') as string[];
return addZerosToStart ? [...zeros, ...segments] : [...segments, ...zeros];
}

export { expandIPv6 };

0 comments on commit f9a8ed9

Please sign in to comment.