feat: remove punycode package (#630)

* feat: remove punycode package

* fix(deno): specify node scope in import
This commit is contained in:
CosminPerRam 2024-09-12 19:45:33 +03:00 committed by GitHub
parent ba2f373986
commit 54f51ebc73
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 9 additions and 5 deletions

View file

@ -1,6 +1,6 @@
import dns from 'node:dns' import dns from 'node:dns'
import { isIP } from 'node:net' import { isIP } from 'node:net'
import punycode from 'punycode/punycode.js' import { domainToASCII } from 'node:url'
export default class DnsResolver { export default class DnsResolver {
/** /**
@ -30,7 +30,11 @@ export default class DnsResolver {
return { address: host } return { address: host }
} }
const asciiForm = punycode.toASCII(host) const asciiForm = domainToASCII(host)
if (!asciiForm) {
throw new Error('Invalid domain')
}
if (asciiForm !== host) { if (asciiForm !== host) {
this.logger.debug('Encoded punycode: ' + host + ' -> ' + asciiForm) this.logger.debug('Encoded punycode: ' + host + ' -> ' + asciiForm)
host = asciiForm host = asciiForm

5
package-lock.json generated
View file

@ -15,7 +15,6 @@
"iconv-lite": "0.6.3", "iconv-lite": "0.6.3",
"long": "5.2.3", "long": "5.2.3",
"minimist": "1.2.8", "minimist": "1.2.8",
"punycode": "2.3.1",
"seek-bzip": "2.0.0", "seek-bzip": "2.0.0",
"varint": "6.0.0" "varint": "6.0.0"
}, },
@ -2839,6 +2838,7 @@
"version": "2.3.1", "version": "2.3.1",
"resolved": "https://registry.npmjs.org/punycode/-/punycode-2.3.1.tgz", "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.3.1.tgz",
"integrity": "sha512-vYt7UD1U9Wg6138shLtLOvdAu+8DsC/ilFtEVHcH+wydcSpNE20AfSOduf6MkRFahL5FY7X1oU7nKVZFtfq8Fg==", "integrity": "sha512-vYt7UD1U9Wg6138shLtLOvdAu+8DsC/ilFtEVHcH+wydcSpNE20AfSOduf6MkRFahL5FY7X1oU7nKVZFtfq8Fg==",
"dev": true,
"engines": { "engines": {
"node": ">=6" "node": ">=6"
} }
@ -5440,7 +5440,8 @@
"punycode": { "punycode": {
"version": "2.3.1", "version": "2.3.1",
"resolved": "https://registry.npmjs.org/punycode/-/punycode-2.3.1.tgz", "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.3.1.tgz",
"integrity": "sha512-vYt7UD1U9Wg6138shLtLOvdAu+8DsC/ilFtEVHcH+wydcSpNE20AfSOduf6MkRFahL5FY7X1oU7nKVZFtfq8Fg==" "integrity": "sha512-vYt7UD1U9Wg6138shLtLOvdAu+8DsC/ilFtEVHcH+wydcSpNE20AfSOduf6MkRFahL5FY7X1oU7nKVZFtfq8Fg==",
"dev": true
}, },
"queue-microtask": { "queue-microtask": {
"version": "1.2.3", "version": "1.2.3",

View file

@ -63,7 +63,6 @@
"iconv-lite": "0.6.3", "iconv-lite": "0.6.3",
"long": "5.2.3", "long": "5.2.3",
"minimist": "1.2.8", "minimist": "1.2.8",
"punycode": "2.3.1",
"seek-bzip": "2.0.0", "seek-bzip": "2.0.0",
"varint": "6.0.0" "varint": "6.0.0"
}, },