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 142 views
1 answer 146 views
1 answer 170 views
2 answers 248 views
1 answer 181 views
1 answer 116 views
116 views asked Aug 10, 2022 by avibootz
...