URL Micro Service Challenge

Hello,

The challenge requirements seem met but I can’t get it to pass test 2 and 3 and there are no errors so I don’t know what else I can do. My guess there’s something i the test that isn’t showing in the requirements page.

Github:

Glitch:
https://functional-goldenrod-sombrero.glitch.me

Any help would be be appreciated.

One thing I did notice is that an address such as “www.glitch.com” will not generate an error on my version. I don’t see why this is a problem since I passes my dns test and works with forwarding.

I could try psl - npm and try to generate an error when a user as an address similar to “www..com”

The FCC tests are passing url like

'https://boilerplate-project-urlshortener.twotani.repl.co/?v=1621725328406'

Is your helper function handling such case too?

I used a URL object. And pull out the properties protocol and hostname for testing.

const urlObj = new URL(req.body.url)
//check urlObj.protocol is http: or https:
//pass urlObj.hostname to dns.lookup

You might give a URL object a try and see if it makes any difference.

1 Like

Good point! No helper function isn’t handling it like it should . I assumed :sweat_smile: it worked because this project used to pass the FCC tests(I didn’t submit it a while ago because I wanted to refactor it). I’ll try experimenting and getting to know the URL better and come back with my findings. Thank you!

Just a quick follow up. It’s working now. The key here would have been to spend more time doing TDD first before trying to refactor the code. Once it worked I refactored it some more.

Also studying the test performed by FCC was a lot of help.

I’ll focus on TDD(Test driven development) for my next projects. Thanks for your help!