Skip to content

Commit

Permalink
fix(t2viz): string escape should only escape field (#325)
Browse files Browse the repository at this point in the history
Signed-off-by: Yulong Ruan <[email protected]>
  • Loading branch information
ruanyl authored Sep 25, 2024
1 parent 93744fe commit 64fb466
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
- feat: check all required agents before enabling index pattern selection for text to visualization([313](https://github.com/opensearch-project/dashboards-assistant/pull/313))
- fix: pass data source id for alert summary/insight([#321](https://github.com/opensearch-project/dashboards-assistant/pull/321))
- feat: support navigating to discover in alerting popover([#316](https://github.com/opensearch-project/dashboards-assistant/pull/316))
- fix: incorrect string escaping of vega schema([325](https://github.com/opensearch-project/dashboards-assistant/pull/325))

### 📈 Features/Enhancements

Expand Down
4 changes: 3 additions & 1 deletion public/components/visualization/text2vega.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,8 @@ export class Text2Vega {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const escapeField = (json: any, field: string) => {
if (json[field]) {
if (typeof json[field] === 'string') {
// Only escape field which name is 'field'
if (typeof json[field] === 'string' && field === 'field') {
json[field] = json[field].replace(/\./g, '\\.');
}
if (typeof json[field] === 'object') {
Expand All @@ -132,6 +133,7 @@ export class Text2Vega {

// need to escape field: geo.city -> field: geo\\.city
escapeField(res, 'encoding');
escapeField(res, 'layer');
return res;
}

Expand Down

0 comments on commit 64fb466

Please sign in to comment.