How to Remove http:// or https:// from a URL in Node.js

1 Answer

0 votes
function removeHttp_s(url) {
  	return url.replace(/^https?:\/\//, '');
}


console.log(removeHttp_s('https://shortinfos.com'));

console.log(removeHttp_s('http://shortinfos.com'));

  
  
  
  
/*
run:
  
shortinfos.com
shortinfos.com
  
*/

 



answered Apr 27, 2022 by avibootz

Related questions

1 answer 143 views
1 answer 148 views
1 answer 172 views
2 answers 252 views
1 answer 183 views
1 answer 120 views
120 views asked Aug 10, 2022 by avibootz
...