I cant seem to find out if the regex or the conditional statement or both is wrong i also cant seem to generate a short url

app.post('/api/shorturl', (req,res,next) => {
  let fullUrl = req.body
  let test = /^https:/.test(fullUrl) 
  if(!test){
    res.json({error: "invalid url"})
  }
  res.json({original_url: fullUrl, short_url: 2})
  next()
})

I’ve edited your code for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.

You can also use the “preformatted text” tool in the editor (</>) to add backticks around text.

See this post to find the backtick on your keyboard.
Note: Backticks (`) are not single quotes (').

Hi, @Wrld_runs_on_Code

Can you please point us to the exercise you are trying to solve?

The Regex in your script come out as true if the fullUrl starts with “https:”.

I just tried this on the developer console of my browser:

/^https:/.test('https://www.google.com/')

Is that what you want?

I believe this might require more work, but without having an idea what you want to achieve or what problem you want to solve it is difficult to say, @Wrld_runs_on_Code

We hope to get more information from you so we can help you better.

Don’t use that regex. If you are doing this locally, it has to support http because the test uses the submitted project URL for the tests. You can also use a package like valid-url or the dns.lookup method from nodejs.