How to match just the root of a URL and not the whole URL from a text string
I found this code but it does not work what is the missing?
$("#divMenu")["append"]("<ul class='myClassId'><li><a href='" + arrLinks[i] + "'><img src='https://www.google.com/s2/favicons?domain=" + tempLink + "'/>" + arrLinks[i]["split"]("//")[1] + "<i class='fa fa-angle-right'></i></a></li></ul>");
https://www.example.com/12xy45
https://example.com/random
http://www.example.com/12xy45
http://example.com/random
resolving to the
www.example.com/12xy45
example.com/random
www.example.com/12xy45
example.com/random
Resolving Not root URL only example: example.com domain.