Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

280
Visualizações
How to listen for string after subdirectory website?

I need to run a JavaScript function when someone goes to https://website.com/custom/U1BJR09U. The U1BJR09U could be any string, but it needs to be passed on to the function. How should I go about implementing this?

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Assuming that all traffic is redirected to a single point that serves a main file handling the URL changes, this should do it:

const hasCustom = window.location.pathname.match(/^\/custom\/([0-9A-Z]+)$/);
if (hasCustom && hasCustom[1]) {
    const myString = hasCustom[1];
    /* Do something with myString here */
}

Explanation of the regexp:

  • ^ starts with\/ (escaped slash)
  • follows with custom
  • has \/ (another slash)
  • Matches ([0-9A-Z]+) numbers and uppercase letters
  • The string ends after numbers and uppercase letters
about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda