Skip to content

Commit

Permalink
fix: Type errors with is-ip module
Browse files Browse the repository at this point in the history
Fixes #127
  • Loading branch information
jhnns committed Jan 21, 2022
1 parent 0184f41 commit 8ea728c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
1 change: 1 addition & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions src/sanitize.ts
@@ -1,4 +1,4 @@
import isIp from "is-ip";
import { version as getIpVersion } from "is-ip";
import { Label } from "./parse-domain";
import { NO_HOSTNAME } from "./from-url";

Expand Down Expand Up @@ -33,7 +33,7 @@ export enum SanitizationResultType {
export type SanitizationResultValidIp = {
type: SanitizationResultType.ValidIp;
ip: string;
ipVersion: Exclude<ReturnType<typeof isIp.version>, undefined>;
ipVersion: Exclude<ReturnType<typeof getIpVersion>, undefined>;
};

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

if (ipVersion !== undefined) {
return {
Expand Down

0 comments on commit 8ea728c

Please sign in to comment.