Skip to content

Commit 78590e1

Browse files
fix: Ref vars without dis strings
1 parent f7ac0a3 commit 78590e1

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

src/datasource.ts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -114,10 +114,16 @@ export class DataSource extends DataSourceWithBackend<HaystackQuery, HaystackDat
114114
case FieldType.string:
115115
if (value.startsWith('@')) {
116116
// Detect ref using @ prefix, and adjust value to just the Ref
117-
let spaceIndex = value.indexOf(' ');
118-
let id = value.substring(0, spaceIndex);
119-
let dis = value.substring(spaceIndex + 2, value.length - 1);
120-
return { text: dis, value: id };
117+
const spaceIndex = value.indexOf(' ');
118+
if (spaceIndex > -1) {
119+
// Display name exists
120+
const id = value.substring(0, spaceIndex);
121+
const dis = value.substring(spaceIndex + 2, value.length - 1);
122+
return { text: dis, value: id };
123+
} else {
124+
// Otherwise, just use id
125+
return { text: value, value: value };
126+
}
121127
} else {
122128
// Otherwise, just use the value directly
123129
return { text: value, value: value };

0 commit comments

Comments
 (0)