Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

106
Views
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 answers
Answer question

0

Remove JSON.stringify and reload your extension. – wOxxOm

This fixed it. Thank you wOxxOm.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!