Skip to content

Commit

Permalink
fixed: navigator check on old runtimes
Browse files Browse the repository at this point in the history
  • Loading branch information
AndreiIgna committed May 23, 2024
1 parent 851f876 commit 5ad4410
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down

0 comments on commit 5ad4410

Please sign in to comment.