Skip to content

Commit f9639f6

Browse files
committed
new URL can throw on error, add try catch
1 parent 1195a23 commit f9639f6

1 file changed

Lines changed: 13 additions & 7 deletions

File tree

lib/tools.js

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -384,16 +384,22 @@ function escapeRegexStr(string) {
384384
}
385385

386386
function getRelayData(url) {
387-
let urlparts = new URL(url);
387+
let urlparts;
388+
try {
389+
urlparts = new URL(url);
390+
} catch {
391+
urlparts = {};
392+
}
388393
let targetMx = {
389394
host: urlparts.hostname,
390395
port: urlparts.port || 25,
391-
auth: urlparts.username || urlparts.password
392-
? {
393-
user: decodeURIComponent(urlparts.username || ''),
394-
pass: decodeURIComponent(urlparts.password || '')
395-
}
396-
: false,
396+
auth:
397+
urlparts.username || urlparts.password
398+
? {
399+
user: decodeURIComponent(urlparts.username || ''),
400+
pass: decodeURIComponent(urlparts.password || '')
401+
}
402+
: false,
397403
secure: urlparts.protocol === 'smtps:',
398404
A: [].concat(net.isIPv4(urlparts.hostname) ? urlparts.hostname : []),
399405
AAAA: [].concat(net.isIPv6(urlparts.hostname) ? urlparts.hostname : [])

0 commit comments

Comments
 (0)