Skip to content

Commit a6be980

Browse files
authored
Merge pull request #99 from Dedac/Rest-Calls-With-non-strings
Add more field types to URL support Resolves #98
2 parents 8184287 + cf779ca commit a6be980

7 files changed

Lines changed: 17 additions & 10 deletions

.DS_Store

-6 KB
Binary file not shown.

azure-devops-extension-dev.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"id":"RestDataMappingPicklistDev",
3-
"version": "0.3.7",
3+
"version": "0.4.0",
44
"baseUri": "https://localhost:44300",
55
"public": false,
66
"private":true

azure-devops-extension.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"manifestVersion": 1.0,
33
"id": "RestDataMappingPicklist",
44
"publisher": "dedac",
5-
"version": "0.3.7",
5+
"version": "0.4.0",
66
"name": "Rest Data Mapping Picklist",
77
"description": "Load work item values from a specified REST endpoint and map additional REST data to your work item",
88
"public": true,

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "rest-data-mapping-picklist",
3-
"version": "0.3.7",
3+
"version": "0.4.0",
44
"description": "An Azure DevOps Work Item Control for loading values from a Rest endpoint",
55
"main": "index.js",
66
"repository": {

src/RestServiceData.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ export class RestServiceData {
1717
}
1818
const keyFieldName = SDK.getConfiguration().witInputs.RestServiceKeyField;
1919
const arrayPath = SDK.getConfiguration().witInputs.PathToArray;
20-
21-
var arrayData = get(resp.data, arrayPath, resp.data);
22-
20+
if (resp !== undefined && resp.data !== undefined) {
21+
var arrayData = get(resp.data, arrayPath, resp.data);
22+
}
2323
if (arrayData) {
2424
if (arrayData.constructor !== Array) {
2525
console.dir(arrayData);

src/parameter-replacement.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,15 @@ export async function ReplaceFieldParameters(hasFields:string) : Promise<string>
1010
var replaceMe = hasFields.substring(index, endIndex + 1);
1111
var fieldName = replaceMe.replace('$(', '').replace(')', '').trim();
1212
var value = await service.getFieldValue(fieldName, { returnOriginalValue: false });
13-
if (typeof value === "string") {
14-
hasFields = hasFields.replace(replaceMe, value);
13+
if (!!value && !!value.toString()) {
14+
var escapedValue = JSON.stringify(value);
15+
// remove outer quotes from the escaped value if they exist
16+
// this assumes the user has added quotes of their own in the configuration
17+
if (escapedValue.startsWith('"') && escapedValue.endsWith('"')) {
18+
escapedValue = escapedValue.substring(1, escapedValue.length - 1);
19+
}
20+
21+
hasFields = hasFields.replace(replaceMe, escapedValue);
1522
} else {
1623
hasFields = hasFields.replace(replaceMe, "");
1724
}

0 commit comments

Comments
 (0)