Created
April 12, 2022 02:55
-
-
Save rinogo/cee6ec7ff300ebb45b1e989f140afcea to your computer and use it in GitHub Desktop.
[Convert URLs to origins (domains)] Convert a list of full URLs into just origins (just the base domains with the protocols)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Convert a list of full URLs into just origins (just the base domains with the protocols) | |
let s = ''; | |
['https://www.whatever.com/narf', | |
'https://beta.something.co.uk/?3920#fjfjf'].map((u) => { | |
let url = new URL(u); | |
s += url.origin + '\n'; | |
}); | |
console.log(s); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment