Faisal
Faisal

Reputation: 604

Get the root domain from url using angular

I have different url for sites like

http://www.abc.com.mypros.fit.edu.co

http://www.abc.com.mypros.library.org

How can I get root domain

mypros.fit.edu.co

mypros.library.org

using typescript in angular 6+

I'm using window.location.host but this does not help, because it returns the url where I need the root url.

Upvotes: 0

Views: 217

Answers (1)

FelixMelix
FelixMelix

Reputation: 248

If your url always starts the same, try using a simple replace:

url.replace('http://www.example.com.','');

Upvotes: 0

Related Questions