Skip to content

Commit 8ea728c

Browse files
committed
fix: Type errors with is-ip module
Fixes #127
1 parent 0184f41 commit 8ea728c

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

package-lock.json

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/sanitize.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import isIp from "is-ip";
1+
import { version as getIpVersion } from "is-ip";
22
import { Label } from "./parse-domain";
33
import { NO_HOSTNAME } from "./from-url";
44

@@ -33,7 +33,7 @@ export enum SanitizationResultType {
3333
export type SanitizationResultValidIp = {
3434
type: SanitizationResultType.ValidIp;
3535
ip: string;
36-
ipVersion: Exclude<ReturnType<typeof isIp.version>, undefined>;
36+
ipVersion: Exclude<ReturnType<typeof getIpVersion>, undefined>;
3737
};
3838

3939
export type SanitizationResultValidDomain = {
@@ -117,7 +117,7 @@ export const sanitize = (
117117
// IPv6 addresses are surrounded by square brackets in URLs
118118
// See https://tools.ietf.org/html/rfc3986#section-3.2.2
119119
const inputTrimmedAsIp = inputTrimmed.replace(/^\[|]$/g, "");
120-
const ipVersion = isIp.version(inputTrimmedAsIp);
120+
const ipVersion = getIpVersion(inputTrimmedAsIp);
121121

122122
if (ipVersion !== undefined) {
123123
return {

0 commit comments

Comments
 (0)