Is there a way to remove http/https and :// from the user input in vanilla JS? [duplicate]
Solution 1:
Try with this:
var url = "https://site.com";
var urlNoProtocol = url.replace(/^https?\:\/\//i, "");
Solution 2:
You can use the URL object like this:
const urlWithoutProtocol = new URL(url).host;