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

107
Visualizações
User input always surrounded by double quotations in concatenated URL

I am developing a Chrome extension that, among other things, allows you to right-click selected text and search for that selected text in a new tab after it's tested against some regular expression patterns.

In the below JavaScript code, the selected text is made into a string, then encoded as a component of a URI, then it is supposed to remove any double quotations from the beginning or end of the variable, but the double quotations are inexorably still in the URL of the newly created tab. I can't figure out what is causing the quotations to show up in the end result in the first place, let alone why they are there even after the .replace method is used. I need there to be no quotations at all and only pass in the selected text into the URL. Please help!

var EncodedSelectedText = encodeURIComponent(JSON.stringify(info.selectionText));
var NoQuotes = EncodedSelectedText.replace(/^"|"$/g, '');

if (RITMRegExPattern.test(info.selectionText)) {
   chrome.tabs.create({
        url: 'https://redacted-site-name.com/sc_req_item_list.do? 
                 sysparm_query=numberLIKE'+NoQuotes
   });
}else if . . .

Resulting URL of the newly created Chrome tab looks like this:

https://redacted-site-name.com/sc_req_item_list.do? 
                 sysparm_query=numberLIKE"abc1234567"

but needs to look like this (without the quotations surrounding abc1234567):

https://redacted-site-name.com/sc_req_item_list.do? 
                 sysparm_query=numberLIKEabc1234567
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Remove JSON.stringify and reload your extension. – wOxxOm

This fixed it. Thank you wOxxOm.

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