@probelabs/probe 0.6.0-rc261 → 0.6.0-rc263

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -70182,12 +70182,31 @@ function cleanSchemaResponse(response) {
70182
70182
  const closeChar = openChar === "{" ? "}" : "]";
70183
70183
  let bracketCount = 1;
70184
70184
  let endIndex = startIndex + 1;
70185
+ let inString = false;
70186
+ let escapeNext = false;
70185
70187
  while (endIndex < trimmed.length && bracketCount > 0) {
70186
70188
  const char = trimmed[endIndex];
70187
- if (char === openChar) {
70188
- bracketCount++;
70189
- } else if (char === closeChar) {
70190
- bracketCount--;
70189
+ if (escapeNext) {
70190
+ escapeNext = false;
70191
+ endIndex++;
70192
+ continue;
70193
+ }
70194
+ if (char === "\\" && inString) {
70195
+ escapeNext = true;
70196
+ endIndex++;
70197
+ continue;
70198
+ }
70199
+ if (char === '"') {
70200
+ inString = !inString;
70201
+ endIndex++;
70202
+ continue;
70203
+ }
70204
+ if (!inString) {
70205
+ if (char === openChar) {
70206
+ bracketCount++;
70207
+ } else if (char === closeChar) {
70208
+ bracketCount--;
70209
+ }
70191
70210
  }
70192
70211
  endIndex++;
70193
70212
  }
@@ -387,18 +387,42 @@ export function cleanSchemaResponse(response) {
387
387
  if (codeBlockMatch && !isCodeBlockEmbeddedInDocument(trimmed, codeBlockMatch)) {
388
388
  const startIndex = codeBlockMatch.index + codeBlockMatch[0].length - 1; // Position of the bracket
389
389
 
390
- // Find the matching closing bracket
390
+ // Find the matching closing bracket (string-aware to avoid miscounting
391
+ // brackets inside JSON string values)
391
392
  const openChar = codeBlockMatch[1];
392
393
  const closeChar = openChar === '{' ? '}' : ']';
393
394
  let bracketCount = 1;
394
395
  let endIndex = startIndex + 1;
396
+ let inString = false;
397
+ let escapeNext = false;
395
398
 
396
399
  while (endIndex < trimmed.length && bracketCount > 0) {
397
400
  const char = trimmed[endIndex];
398
- if (char === openChar) {
399
- bracketCount++;
400
- } else if (char === closeChar) {
401
- bracketCount--;
401
+
402
+ if (escapeNext) {
403
+ escapeNext = false;
404
+ endIndex++;
405
+ continue;
406
+ }
407
+
408
+ if (char === '\\' && inString) {
409
+ escapeNext = true;
410
+ endIndex++;
411
+ continue;
412
+ }
413
+
414
+ if (char === '"') {
415
+ inString = !inString;
416
+ endIndex++;
417
+ continue;
418
+ }
419
+
420
+ if (!inString) {
421
+ if (char === openChar) {
422
+ bracketCount++;
423
+ } else if (char === closeChar) {
424
+ bracketCount--;
425
+ }
402
426
  }
403
427
  endIndex++;
404
428
  }
@@ -97068,12 +97068,31 @@ function cleanSchemaResponse(response) {
97068
97068
  const closeChar = openChar === "{" ? "}" : "]";
97069
97069
  let bracketCount = 1;
97070
97070
  let endIndex = startIndex + 1;
97071
+ let inString = false;
97072
+ let escapeNext = false;
97071
97073
  while (endIndex < trimmed.length && bracketCount > 0) {
97072
97074
  const char = trimmed[endIndex];
97073
- if (char === openChar) {
97074
- bracketCount++;
97075
- } else if (char === closeChar) {
97076
- bracketCount--;
97075
+ if (escapeNext) {
97076
+ escapeNext = false;
97077
+ endIndex++;
97078
+ continue;
97079
+ }
97080
+ if (char === "\\" && inString) {
97081
+ escapeNext = true;
97082
+ endIndex++;
97083
+ continue;
97084
+ }
97085
+ if (char === '"') {
97086
+ inString = !inString;
97087
+ endIndex++;
97088
+ continue;
97089
+ }
97090
+ if (!inString) {
97091
+ if (char === openChar) {
97092
+ bracketCount++;
97093
+ } else if (char === closeChar) {
97094
+ bracketCount--;
97095
+ }
97077
97096
  }
97078
97097
  endIndex++;
97079
97098
  }
package/cjs/index.cjs CHANGED
@@ -82851,12 +82851,31 @@ function cleanSchemaResponse(response) {
82851
82851
  const closeChar = openChar === "{" ? "}" : "]";
82852
82852
  let bracketCount = 1;
82853
82853
  let endIndex = startIndex + 1;
82854
+ let inString = false;
82855
+ let escapeNext = false;
82854
82856
  while (endIndex < trimmed.length && bracketCount > 0) {
82855
82857
  const char = trimmed[endIndex];
82856
- if (char === openChar) {
82857
- bracketCount++;
82858
- } else if (char === closeChar) {
82859
- bracketCount--;
82858
+ if (escapeNext) {
82859
+ escapeNext = false;
82860
+ endIndex++;
82861
+ continue;
82862
+ }
82863
+ if (char === "\\" && inString) {
82864
+ escapeNext = true;
82865
+ endIndex++;
82866
+ continue;
82867
+ }
82868
+ if (char === '"') {
82869
+ inString = !inString;
82870
+ endIndex++;
82871
+ continue;
82872
+ }
82873
+ if (!inString) {
82874
+ if (char === openChar) {
82875
+ bracketCount++;
82876
+ } else if (char === closeChar) {
82877
+ bracketCount--;
82878
+ }
82860
82879
  }
82861
82880
  endIndex++;
82862
82881
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@probelabs/probe",
3
- "version": "0.6.0-rc261",
3
+ "version": "0.6.0-rc263",
4
4
  "description": "Node.js wrapper for the probe code search tool",
5
5
  "main": "src/index.js",
6
6
  "module": "src/index.js",
@@ -387,18 +387,42 @@ export function cleanSchemaResponse(response) {
387
387
  if (codeBlockMatch && !isCodeBlockEmbeddedInDocument(trimmed, codeBlockMatch)) {
388
388
  const startIndex = codeBlockMatch.index + codeBlockMatch[0].length - 1; // Position of the bracket
389
389
 
390
- // Find the matching closing bracket
390
+ // Find the matching closing bracket (string-aware to avoid miscounting
391
+ // brackets inside JSON string values)
391
392
  const openChar = codeBlockMatch[1];
392
393
  const closeChar = openChar === '{' ? '}' : ']';
393
394
  let bracketCount = 1;
394
395
  let endIndex = startIndex + 1;
396
+ let inString = false;
397
+ let escapeNext = false;
395
398
 
396
399
  while (endIndex < trimmed.length && bracketCount > 0) {
397
400
  const char = trimmed[endIndex];
398
- if (char === openChar) {
399
- bracketCount++;
400
- } else if (char === closeChar) {
401
- bracketCount--;
401
+
402
+ if (escapeNext) {
403
+ escapeNext = false;
404
+ endIndex++;
405
+ continue;
406
+ }
407
+
408
+ if (char === '\\' && inString) {
409
+ escapeNext = true;
410
+ endIndex++;
411
+ continue;
412
+ }
413
+
414
+ if (char === '"') {
415
+ inString = !inString;
416
+ endIndex++;
417
+ continue;
418
+ }
419
+
420
+ if (!inString) {
421
+ if (char === openChar) {
422
+ bracketCount++;
423
+ } else if (char === closeChar) {
424
+ bracketCount--;
425
+ }
402
426
  }
403
427
  endIndex++;
404
428
  }