From 5ad4410734725e2b359332db960b46e935c55d94 Mon Sep 17 00:00:00 2001 From: Andrei Date: Thu, 23 May 2024 17:20:07 +0200 Subject: [PATCH] fixed: navigator check on old runtimes --- dist/index.js | 4 ++-- src/index.ts | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/dist/index.js b/dist/index.js index 7a0f5ca..8343a03 100644 --- a/dist/index.js +++ b/dist/index.js @@ -24,10 +24,10 @@ const isDomain = (domain) => { }); }; function bestDnsResolverForThisRuntime() { - if (navigator.userAgent === 'Cloudflare-Workers') { + if (navigator?.userAgent === 'Cloudflare-Workers') { return 'cloudflare-dns'; } - else if (navigator.userAgent.startsWith('Node.js/')) { + else if (navigator?.userAgent.startsWith('Node.js/')) { return 'node-dns'; } else { diff --git a/src/index.ts b/src/index.ts index cc9018f..3b93706 100644 --- a/src/index.ts +++ b/src/index.ts @@ -42,9 +42,9 @@ const isDomain = (domain: string): boolean => { } function bestDnsResolverForThisRuntime(): string { - if (navigator.userAgent === 'Cloudflare-Workers') { + if (navigator?.userAgent === 'Cloudflare-Workers') { return 'cloudflare-dns' - } else if (navigator.userAgent.startsWith('Node.js/')) { + } else if (navigator?.userAgent.startsWith('Node.js/')) { return 'node-dns' } else { return 'google-dns'