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

195
Vistas
Chrome extension: How to make my tabs query return the URL without anything after the .com/

I would like to get the URL as the website's domain name rather than having the extra parts after the ".com/"

Currently when I query tabs with chrome.tabs.query(params, function(){...}); the URL will still contain all the content about the specific page rather than just being the website's domain

How should I go about this so that it will also work with .ca or .gov as well? Is there a trick to shrink the string after the domain ends or will I have to look for string patterns in the URL for each different ending

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

0

You can parse the result and extract the domain name from it.

let result = 'https://example.com/some/after?=after:stuf&';
const url = new URL(result);
const domain = url.hostname;
console.log(domain);

OUTPUT

example.com
about 4 years ago · Juan Pablo Isaza Denunciar

0

Given Tab.url is a plain string, you can run it through the URL constructor and get the origin from that

// just for the demo
const tabs = [{
  url: "https://stackoverflow.com/questions/73524018/chrome-extension-how-to-make-my-tabs-query-return-the-url-without-anything-afte",
}, {
  url: "https://example.com/foo/bar/baz?msg=Hello%20World",
}];

const origins = tabs.map(({ url }) => new URL(url).origin);
console.log(origins);

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