(toEscape)
| 462 | } |
| 463 | |
| 464 | function 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 | |
| 491 | function getLongestSubstringWithoutSpace(text) { |
| 492 | let words = text.split(' ') |
no test coverage detected