Skip to content

Commit

Permalink
Rename checkInterfaceAddress() -> canonicalizeAddress().
Browse files Browse the repository at this point in the history
  • Loading branch information
danfuzz committed Dec 5, 2024
1 parent 1d50c01 commit d891839
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
6 changes: 3 additions & 3 deletions src/net-util/export/InterfaceAddress.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ export class InterfaceAddress extends IntfDeconstructable {
}

if (address) {
address = InterfaceAddress.checkInterfaceAddress(address);
address = InterfaceAddress.canonicalizeAddress(address);
if (portNumber === null) {
throw new Error('Must pass `portNumber` when using `address`.');
}
Expand Down Expand Up @@ -305,7 +305,7 @@ export class InterfaceAddress extends IntfDeconstructable {
* pattern.
* @throws {Error} Thrown if `value` does not match.
*/
static checkInterfaceAddress(value) {
static canonicalizeAddress(value) {
const canonicalIp = EndpointAddress.canonicalizeAddressOrNull(value, false);
if (canonicalIp) {
return canonicalIp;
Expand Down Expand Up @@ -400,7 +400,7 @@ export class InterfaceAddress extends IntfDeconstructable {
return (port === null) ? { fd } : { fd, port };
}

const address = InterfaceAddress.checkInterfaceAddress(addressOrFd.address);
const address = InterfaceAddress.canonicalizeAddress(addressOrFd.address);

if (/^(?!\[).*:.*:/.test(iface)) {
// If we managed to parse and made it here, then we are necessarily
Expand Down
8 changes: 4 additions & 4 deletions src/net-util/tests/InterfaceAddress.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ describe('toString()', () => {
// Static members
//

describe('checkInterfaceAddress()', () => {
describe('canonicalizeAddress()', () => {
const LONGEST_COMPONENT = 'x'.repeat(63);
const LONGEST_NAME = `${'florp.'.repeat(41)}vwxyz.com`;

Expand Down Expand Up @@ -409,7 +409,7 @@ describe('checkInterfaceAddress()', () => {
${'IPv6 with extra at end'} | ${'aa:bc::1:2:34z'}
${'IPv4-in-v6 but with wrong prefix'} | ${'1234::78:10.20.30.40'}
`('fails for $label', ({ iface }) => {
expect(() => InterfaceAddress.checkInterfaceAddress(iface)).toThrow();
expect(() => InterfaceAddress.canonicalizeAddress(iface)).toThrow();
});

// Success cases that are given in canonical form.
Expand Down Expand Up @@ -439,7 +439,7 @@ describe('checkInterfaceAddress()', () => {
${`${LONGEST_COMPONENT}.${LONGEST_COMPONENT}`}
${LONGEST_NAME}
`('succeeds for $iface', ({ iface }) => {
const got = InterfaceAddress.checkInterfaceAddress(iface);
const got = InterfaceAddress.canonicalizeAddress(iface);
const expected = iface.replace(/\[|\]/g, '');
expect(got).toBe(expected);
});
Expand All @@ -457,7 +457,7 @@ describe('checkInterfaceAddress()', () => {
${'[12:Ab::34:cD]'} | ${'12:ab::34:cd'}
${'::ffff:102:304'} | ${'::ffff:1.2.3.4'} // IPv4-in-v6 wrapped form
`('returns `$expected` given `$iface`', ({ iface, expected }) => {
const got = InterfaceAddress.checkInterfaceAddress(iface);
const got = InterfaceAddress.canonicalizeAddress(iface);
expect(got).toBe(expected);
});
});
Expand Down

0 comments on commit d891839

Please sign in to comment.