Tell us what’s happening:
My second and third test conditions are not passing, even though the code works perfectly as it should; redirects, and returns proper response.
You can check my code below
require('dotenv').config();
const express = require('express');
const bodyParser = require('body-parser');
const dns = require('dns');
const cors = require('cors');
const app = express();
// Basic Configuration
const port = process.env.PORT || 3000;
// Mount body-parser middleware
app.use(bodyParser.urlencoded({ extended: false }));
app.use(cors());
app.use('/public', express.static(`${process.cwd()}/public`));
app.get('/', function (req, res) {
res.sendFile(process.cwd() + '/views/index.html');
});
This file has been truncated. show original
###Your project link(s)
solution: http://localhost:3000
githubLink: GitHub - OluwaFavour/url_shortener
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36
Challenge Information:
Back End Development and APIs Projects - URL Shortener Microservice
Learn to Code — For Free
Is this challenge still unsolved?
Yeah… I read through the previous solutions on the forum, and my issue is different.
Even though it’s working as expected
1 Like
Your URL validation isn’t working. Submit and look at the response in the browser dev tools (network tab).
The dns method only takes a hostname. You can use the URL constructor to get it.
new URL(url).hostname
2 Likes
It workeddd!!!
Thanks for the tip lasjorg.
I just added the const hostname = new URL(url).hostname
line like you said and passed it to the dns method instead of the hostname I got by splitting the url with the /
seperator
system
Closed
October 26, 2024, 6:34am
6
This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.