Urlshortener dns.lookup

Tell us what’s happening:
When I am doing dns.lookup on john-doe.org which is one of the test cases it is actually returning valid IP address and that’s why that is failing. Please change the test case.

Your project link(s)

solution: https://replit.com/@sroy8091/urlshortener

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:88.0) Gecko/20100101 Firefox/88.0

Challenge: URL Shortener Microservice

Link to the challenge:

1 Like

You have this

 if (urlObject.protocol != 'https:' || urlObject.protocol != 'http:'){
        return res.json({ error: 'invalid url' })

This is a wrong test. It should be

if (urlObject.protocol !== 'http:' && urlObject.protocol !== 'https:') {
    return res.json({'error': 'invalid url'})

If the protocol is ‘http:’ or protocol is ‘https:’, then it is valid. So, negating it becomes
if (not (protocol === ‘http:’ or protocol === ‘https:’)) then invalid
Distributing negation (de Morgan’s law), it becomes
if (protocol !== ‘http:’ AND protocol !== ‘https:’)

1 Like

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.