mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 10:58:30 -05:00
make the json regex better (#20826)
* make the json regex better * comment
This commit is contained in:
@@ -73,7 +73,9 @@ const MIN_GRID_HEIGHT = (MIN_GRID_HEIGHT_ROWS * ROW_HEIGHT) + HEADER_HEIGHT + ES
|
|||||||
// 2. when user clicks a cell, whether the cell content should be displayed in a new text editor as json.
|
// 2. when user clicks a cell, whether the cell content should be displayed in a new text editor as json.
|
||||||
// Based on the requirements, the solution doesn't need to be very accurate, a simple regex is enough since it is more
|
// Based on the requirements, the solution doesn't need to be very accurate, a simple regex is enough since it is more
|
||||||
// performant than trying to parse the string to object.
|
// performant than trying to parse the string to object.
|
||||||
const IsJsonRegex = /({.*?})/g;
|
// Regex explaination: after removing the trailing whitespaces, the string must start with '[' (to support arrays)
|
||||||
|
// or '{'. And there must be a '}' to match the '{'.
|
||||||
|
const IsJsonRegex = /^\s*\[*\s*{.*?}/g;
|
||||||
|
|
||||||
export class GridPanel extends Disposable {
|
export class GridPanel extends Disposable {
|
||||||
private container = document.createElement('div');
|
private container = document.createElement('div');
|
||||||
|
|||||||
Reference in New Issue
Block a user