Skip to content

Commit

Permalink
refactor: dynamic import node:dns
Browse files Browse the repository at this point in the history
  • Loading branch information
Julien-R44 committed Nov 28, 2023
1 parent 1e5b5c4 commit 92a48c8
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/vine/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import isAlpha from 'validator/lib/isAlpha.js'
import isLatLong from 'validator/lib/isLatLong.js'
import isDecimal from 'validator/lib/isDecimal.js'
import isHexColor from 'validator/lib/isHexColor.js'
import { resolve4, resolve6 } from 'node:dns/promises'
import isCreditCard from 'validator/lib/isCreditCard.js'
import isAlphanumeric from 'validator/lib/isAlphanumeric.js'
import isPassportNumber from 'validator/lib/isPassportNumber.js'
Expand Down Expand Up @@ -243,6 +242,8 @@ export const helpers = {
* Check if a URL has valid `A` or `AAAA` DNS records
*/
isActiveURL: async (url: string): Promise<boolean> => {
const { resolve4, resolve6 } = await import('node:dns/promises')

try {
const { hostname } = new URL(url)
const v6Addresses = await resolve6(hostname)
Expand Down

0 comments on commit 92a48c8

Please sign in to comment.