Skip to content

Commit

Permalink
updated: nodejs runtime detection
Browse files Browse the repository at this point in the history
  • Loading branch information
AndreiIgna committed May 23, 2024
1 parent 5ad4410 commit e4dc8bd
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
8 changes: 4 additions & 4 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ const isDomain = (domain) => {
});
};
function bestDnsResolverForThisRuntime() {
if (navigator?.userAgent === 'Cloudflare-Workers') {
return 'cloudflare-dns';
}
else if (navigator?.userAgent.startsWith('Node.js/')) {
if (globalThis.process?.release?.name === 'node') {
return 'node-dns';
}
else if (globalThis.navigator?.userAgent === 'Cloudflare-Workers') {
return 'cloudflare-dns';
}
else {
return 'google-dns';
}
Expand Down
6 changes: 3 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@ const isDomain = (domain: string): boolean => {
}

function bestDnsResolverForThisRuntime(): string {
if (navigator?.userAgent === 'Cloudflare-Workers') {
return 'cloudflare-dns'
} else if (navigator?.userAgent.startsWith('Node.js/')) {
if (globalThis.process?.release?.name === 'node') {
return 'node-dns'
} else if (globalThis.navigator?.userAgent === 'Cloudflare-Workers') {
return 'cloudflare-dns'
} else {
return 'google-dns'
}
Expand Down

0 comments on commit e4dc8bd

Please sign in to comment.