MCPcopy Index your code
hub / github.com/SeleniumHQ/selenium / escapeQuotes

Function escapeQuotes

javascript/selenium-webdriver/lib/select.js:464–489  ·  view source on GitHub ↗
(toEscape)

Source from the content-addressed store, hash-verified

462}
463
464function escapeQuotes(toEscape) {
465 if (toEscape.includes(`"`) && toEscape.includes(`'`)) {
466 const quoteIsLast = toEscape.lastIndexOf(`"`) === toEscape.length - 1
467 const substrings = toEscape.split(`"`)
468
469 // Remove the last element if it's an empty string
470 if (substrings[substrings.length - 1] === '') {
471 substrings.pop()
472 }
473
474 let result = 'concat('
475
476 for (let i = 0; i < substrings.length; i++) {
477 result += `"${substrings[i]}"`
478 result += i === substrings.length - 1 ? (quoteIsLast ? `, '"')` : `)`) : `, '"', `
479 }
480 return result
481 }
482
483 if (toEscape.includes('"')) {
484 return `'${toEscape}'`
485 }
486
487 // Otherwise return the quoted string
488 return `"${toEscape}"`
489}
490
491function getLongestSubstringWithoutSpace(text) {
492 let words = text.split(' ')

Callers 5

selectByValueMethod · 0.85
selectByVisibleTextMethod · 0.85
deselectByVisibleTextMethod · 0.85
deselectByValueMethod · 0.85
select_test.jsFile · 0.85

Calls 1

splitMethod · 0.80

Tested by

no test coverage detected