fk19
March 10, 2023, 10:35pm
1
Tell us what’s happening:
dns.lookup doesn’t work when i get the hostname from the url - it accepts all kinds of strings as valid hostnames. When i test manually with a string containing ‘example’ it works.
Your project link(s)
solution: boilerplate-project-urlshortener - Replit
Your browser information:
User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/15.6.1 Safari/605.1.15
Challenge: Back End Development and APIs Projects - URL Shortener Microservice
Link to the challenge:
url.parse is deprecated. Use the URL constructor instead (WHATWG URL API ).
const url = require('url');
const dns = require("dns");
const nodeURL = url.parse('ftp:/john-doe.invalidTLD').hostname;
const WHATWG_URL = new URL('ftp:/john-doe.invalidTLD').hostname
console.log(nodeURL) // null
console.log(WHATWG_URL) // ftp:/john-doe.invalidTLD
dns.lookup(nodeURL, (error, address, family) => {
if (error) {
console.error(error);
} else {
console.error('No error'); // No error
}
});
system
Closed
September 9, 2023, 1:09pm
4
This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.