Skip to content

Commit

Permalink
Merge pull request #99 from Dedac/Rest-Calls-With-non-strings
Browse files Browse the repository at this point in the history
Add more field types to URL support Resolves #98
  • Loading branch information
Dedac committed Aug 22, 2022
2 parents 8184287 + cf779ca commit a6be980
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 10 deletions.
Binary file removed .DS_Store
Binary file not shown.
2 changes: 1 addition & 1 deletion azure-devops-extension-dev.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"id":"RestDataMappingPicklistDev",
"version": "0.3.7",
"version": "0.4.0",
"baseUri": "https://localhost:44300",
"public": false,
"private":true
Expand Down
2 changes: 1 addition & 1 deletion azure-devops-extension.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"manifestVersion": 1.0,
"id": "RestDataMappingPicklist",
"publisher": "dedac",
"version": "0.3.7",
"version": "0.4.0",
"name": "Rest Data Mapping Picklist",
"description": "Load work item values from a specified REST endpoint and map additional REST data to your work item",
"public": true,
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "rest-data-mapping-picklist",
"version": "0.3.7",
"version": "0.4.0",
"description": "An Azure DevOps Work Item Control for loading values from a Rest endpoint",
"main": "index.js",
"repository": {
Expand Down
6 changes: 3 additions & 3 deletions src/RestServiceData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ export class RestServiceData {
}
const keyFieldName = SDK.getConfiguration().witInputs.RestServiceKeyField;
const arrayPath = SDK.getConfiguration().witInputs.PathToArray;

var arrayData = get(resp.data, arrayPath, resp.data);

if (resp !== undefined && resp.data !== undefined) {
var arrayData = get(resp.data, arrayPath, resp.data);
}
if (arrayData) {
if (arrayData.constructor !== Array) {
console.dir(arrayData);
Expand Down
11 changes: 9 additions & 2 deletions src/parameter-replacement.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,15 @@ export async function ReplaceFieldParameters(hasFields:string) : Promise<string>
var replaceMe = hasFields.substring(index, endIndex + 1);
var fieldName = replaceMe.replace('$(', '').replace(')', '').trim();
var value = await service.getFieldValue(fieldName, { returnOriginalValue: false });
if (typeof value === "string") {
hasFields = hasFields.replace(replaceMe, value);
if (!!value && !!value.toString()) {
var escapedValue = JSON.stringify(value);
// remove outer quotes from the escaped value if they exist
// this assumes the user has added quotes of their own in the configuration
if (escapedValue.startsWith('"') && escapedValue.endsWith('"')) {
escapedValue = escapedValue.substring(1, escapedValue.length - 1);
}

hasFields = hasFields.replace(replaceMe, escapedValue);
} else {
hasFields = hasFields.replace(replaceMe, "");
}
Expand Down

0 comments on commit a6be980

Please sign in to comment.