Do you know guys why my tests won’t pass? I will be grateful for any help
solution: https://replit.com/@kubawasowicz/boilerplate-project-urlshortener-1
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.99 Safari/537.36
Challenge: URL Shortener Microservice
Link to the challenge:
This:
dns.lookup(url.replace(urlRegex,
""), async (err, address, family) => {
if (err || !urlRegex.test(url)) {
res.json({ error: "Invalid URL" })
} else {
Log that first argument to dns.lookup()
; it’s not just the hostname as the function requires. There was another similar problem just today about this. Your code is flagging all URLs as invalid.
Also, be careful about mixing async/await
and a callback (the second argument to dns.lookup()
. Either use the callback version or use the async version.
Google the dns.lookup()
documentation for more details.