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

105
Vistas
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 Respuestas
Responde la pregunta

0

Remove JSON.stringify and reload your extension. – wOxxOm

This fixed it. Thank you wOxxOm.

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