Skip to content

Commit 4f8425a

Browse files
committed
INT-753 fix regex for unquoted keys in refine bar
1 parent 85786bd commit 4f8425a

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/models/editable-query.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,10 @@ module.exports = Model.extend({
2828
if (_.trim(output) === '') {
2929
output = '{}';
3030
}
31-
// wrap field names in double quotes
32-
output = output.replace(/([{,])\s*([^,{\s\'"]+)\s*:/g, ' $1 "$2" : ');
31+
// wrap field names in double quotes. I appologize for the next line of code.
32+
// @see http://stackoverflow.com/questions/6462578/alternative-to-regex-match-all-instances-not-inside-quotes
33+
// @see https://regex101.com/r/xM7iH6/1
34+
output = output.replace(/([{,])\s*([^,{\s\'"]+)\s*:(?=([^"\\]*(\\.|"([^"\\]*\\.)*[^"\\]*"))*[^"]*$)/g, '$1"$2":');
3335
// replace multiple whitespace with single whitespace
3436
output = output.replace(/\s+/g, ' ');
3537
return output;

0 commit comments

Comments
 (0)