Skip to content

Revision 0.11.5#16

Merged
sinclairzx81 merged 3 commits into
mainfrom
escape
Jun 5, 2026
Merged

Revision 0.11.5#16
sinclairzx81 merged 3 commits into
mainfrom
escape

Conversation

@sinclairzx81

Copy link
Copy Markdown
Owner

This PR fixes an unescaped double backslash which has surfaced in TB's key patterns.

// This is a TypeBox Numeric Pattern
export const NumberPattern = '-?(?:0|[1-9][0-9]*)(?:\\.[0-9]+)?'

// Where `\\` in `(?:\\.[0-9]+)` was unescaped to `(?:\.[0-9]+)` (Script Parser)
export const PatternNumber = 
  (input: string): [unknown, string] | [] =>
    If(Token.Const('-?(?:0|[1-9][0-9]*)(?:\.[0-9]+)?', input), 
     ([_0, input]) => ...

This PR adds the following // escape.

export function Escape(input: string): string {
  return input.replace(/\\/g, '\\\\') // <--- here
    .replace(/\n/g, "\\n")
    .replace(/\r/g, "\\r")
    .replace(/"/g, '\\"')
    .replace(/'/g, "\\'");
}

@sinclairzx81 sinclairzx81 merged commit a2b03fd into main Jun 5, 2026
6 checks passed
@sinclairzx81 sinclairzx81 deleted the escape branch June 5, 2026 03:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant