Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

295
Vistas
How to get subdomain from url

I have a url like http://abc.xyz.com. I just want 'http://abc' part, But I am getting 'http://abc.xyz.com'

I tried this:

windw.location.origin

Do I need to write some extra method to get the first part of url or is there something any window method which will do the same?

about 4 years ago · Juan Pablo Isaza
3 Respuestas
Responde la pregunta

0

You can split it by . and take the first element

window.location.origin.split('.')[0]

Example:

console.log(window.location.origin);
console.log(window.location.origin.split('.')[0]);

about 4 years ago · Juan Pablo Isaza Denunciar

0

"http://abc.xyz.com".split(".")[0]
// or
var url = "http://abc.xyz.com";
url.split(".")[0]

returns "http://abc"

about 4 years ago · Juan Pablo Isaza Denunciar

0

It's as simple as that: [subdomain] = 'https://abc.def.xyz'.split('.');

var url = 'https://abc.def.xyz';
[subdomain] = url.split('.');
console.log(subdomain);

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda