JSFiddle - React, Tailwind, and code Playground

HTML

<input type='text' class='site'/>

JavaScript

$(".site").keyup(function()
{
   var site=$(this).val();
   var exp = /^http(s?):\/\/(\w+:{0,1}\w*)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?/;
   var find = site.match(exp);

   var url = find? find[0] : null;

     if (url === null){
        var exp = /[-\w]+(\.[a-z]{2,})+(\S+)?(\/|\/[\w#!:.?+=&%@!\-\/])?/g;
        var find = site.match(exp);
        url = find? 'http://'+find[0] : null;
      }
    console.log(site);
});