MCPcopy Index your code
hub / github.com/anomalyco/opencode / unescapeString

Function unescapeString

packages/opencode/src/tool/edit.ts:500–525  ·  view source on GitHub ↗
(str: string)

Source from the content-addressed store, hash-verified

498
499export const EscapeNormalizedReplacer: Replacer = function* (content, find) {
500 const unescapeString = (str: string): string => {
501 return str.replace(/\\(n|t|r|'|"|`|\\|\n|\$)/g, (match, capturedChar) => {
502 switch (capturedChar) {
503 case "n":
504 return "\n"
505 case "t":
506 return "\t"
507 case "r":
508 return "\r"
509 case "'":
510 return "'"
511 case '"':
512 return '"'
513 case "`":
514 return "`"
515 case "\\":
516 return "\\"
517 case "\n":
518 return "\n"
519 case "$":
520 return "$"
521 default:
522 return match
523 }
524 })
525 }
526
527 const unescapedFind = unescapeString(find)
528

Callers 1

edit.tsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected