sid heart
sid heart

Reputation: 1149

How to get client origin in vue

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

Answers (1)

Boussadjra Brahim
Boussadjra Brahim

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

Related Questions