So my code on replit is working as expected but freecodecamp is failing me for this challenge.
project link(s)
solution: https://replit.com/@hobableo/boilerplate-project-urlshortener
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/99.0.4844.51 Safari/537.36
Challenge: URL Shortener Microservice
Link to the challenge:
jenovs
March 13, 2022, 7:32am
2
Instead of doing this:
const REPLACE_REGEX = /^https?:\/\//i
const url2 = url.replace(REPLACE_REGEX, '');
you should do this:
const url2 = new URL(url).hostname;
1 Like
Thank you so much, brother. It did worked.
For clarification I have this one question. The above regex although does the same why wont it work.
jenovs
March 14, 2022, 6:41am
4
Not quite. The regex only removes protocol (https), but leaves query (stuff that goes at the end after ?
). And if you check the docs for dns , you’ll see that it requires hostname as the first argument.
1 Like
system
Closed
September 12, 2022, 6:42pm
5
This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.