Help with node.js dns.lookup()

I am having trouble with dns.lookup() with some URLs (URL shortener project, finished it but trying to remove bugs). For example this URL, which is valid: https://guide.freecodecamp.org/jquery/jquery-ajax-post-method
I get this error message:

{ Error: getaddrinfo ENOTFOUND guide.freecodecamp.org/jquery/jquery-ajax-post-method
    at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:56:26)
  errno: 'ENOTFOUND',
  code: 'ENOTFOUND',
  syscall: 'getaddrinfo',
  hostname: 'guide.freecodecamp.org/jquery/jquery-ajax-post-method' }

In my server.js file:

var regex = /^https?:\/\//; //need this format for res.redirect
  
  if (regex.test(url)) {
  var dnsUrl = url.slice(url.indexOf("//") + 2); //need to remove http(s):// to pass to dns.lookup
  dns.lookup(dnsUrl, function(err, address, family) {  //check for valid url
    if (err) { console.log(err); }
    else if (address !== undefined) {
      console.log("address: " + address);
      findOriginalUrl(url); //check to see if url exists in database
    } else {
      res.send("not a valid URL");
      console.log("dnsUrl: " + dnsUrl);
    }
  });  //dns.lookup
  } else {
  res.send("invalid URL format");
}
});

This is my code on glitch.
This is my app.

Apparently dns.lookup() doesn’t like anything after .com or .biz etc. So I had to slice off what is after that to make it work.

 var regex = /^https?:\/\//; //need this format for res.redirect
  
  if (regex.test(url)) {
  var tempDnsUrl = url.slice(url.indexOf("//") + 2); //need to remove http(s):// to pass to dns.lookup
  var slashIndex = tempDnsUrl.indexOf("/"); //need to remove anythng past .com, etc., for dns.lookup
  var dnsUrl = slashIndex < 0 ? tempDnsUrl : tempDnsUrl.slice(0, slashIndex); 
  console.log("slashIndex: " + slashIndex);
  console.log("dnsUrl: " + dnsUrl);
  dns.lookup(dnsUrl, function(err, address, family) {  //check for valid url
    if (err) { 
      console.log(err); 
      res.send("not a valid URL");
    }
    else if (address !== undefined) {
      console.log("address: " + address);
      findOriginalUrl(url); //check to see if url exists in database
    } 
  });  //dns.lookup
  } else {
  res.send("invalid URL format");
}
});