Reputation: 1149
i have multiple domains for example https://www.ilajobs.com
levelcoding.com
when i try to get client origin like this
getOrigin() {
this.origin = window.location.origin;
},
expected result
ilajobs
what i am getting
https://www.ilajobs.com
how to remove TLD from origin
Upvotes: 2
Views: 2644
Reputation: 1
Try host property because origin one returns the domain name and the protocol :
getOrigin() {
let host=window.location.host
this.origin =host.slice(0,host.lastIndexOf('.'));
},
this remove the .com
or .origin
(TLD)
Upvotes: 4