From cf779ca5ca8514db4443eb9d6fb6bda21da86fa9 Mon Sep 17 00:00:00 2001 From: Richard Goforth Date: Mon, 22 Aug 2022 16:22:11 +0000 Subject: [PATCH] Add more field types to URL support --- .DS_Store | Bin 6148 -> 0 bytes azure-devops-extension-dev.json | 2 +- azure-devops-extension.json | 2 +- package-lock.json | 4 ++-- package.json | 2 +- src/RestServiceData.ts | 6 +++--- src/parameter-replacement.ts | 11 +++++++++-- 7 files changed, 17 insertions(+), 10 deletions(-) delete mode 100644 .DS_Store diff --git a/.DS_Store b/.DS_Store deleted file mode 100644 index ccfb707c2a0556b24020e9ddc4bf11a84aaba967..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 6148 zcmeHK%T59@6g>qJQIVi46JwkofW$u-5f&!uLOwv{AwiKbyfm(6??3npexEBnw{4IX zh;d_#=_S3V?c8(QIWyBz0IE7^9|9!+c^1Lk2Hg^q>rxghV|$83rE_#pMjIVWkt{@q zj-WtL;IAnl-|hjf@r((E{Bpm(-v^A?>fi}u`T<)#e$|6nLL>@Ij%E3jz3;9`s>{2Sw`KX>qSYn`KUFV;snR2;~Wjt-DtJ% zMHi?-qSv`g=9bz7eQGrFcrPArld)6A4e5KtM^wmfd#rblwT%ZV*uousm#i|!N_2aL zR++Asq2Og$!ILMaigViSkSFiNm_M2Ckn?SE>;Z1r?y|)RFN}M(Sbo!B z@Iir~Ku}<&fUFM@i(qUqHK>;kI(-Bn=Gd)`b@>w@oXBEqF*V35G-aqnLsj;Op$wh< zk&TNjrUnfi${s$H9a-5EiqfMqf26~qVuQg41%d*u0$I~6$^Ktoeg1bzp%oMe3j8Yt zRIb*jRe4KxZ(X=K*=r+~D;6<{OATrYo!yRgMYiHy7Hzy1Nrf0&ObxP!7XAom8G;K6 H{Hg+R diff --git a/azure-devops-extension-dev.json b/azure-devops-extension-dev.json index 8328e73..0cf977d 100644 --- a/azure-devops-extension-dev.json +++ b/azure-devops-extension-dev.json @@ -1,6 +1,6 @@ { "id":"RestDataMappingPicklistDev", - "version": "0.3.7", + "version": "0.4.0", "baseUri": "https://localhost:44300", "public": false, "private":true diff --git a/azure-devops-extension.json b/azure-devops-extension.json index 5dcf62c..8916df6 100644 --- a/azure-devops-extension.json +++ b/azure-devops-extension.json @@ -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, diff --git a/package-lock.json b/package-lock.json index 44bf564..64d8878 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "rest-data-mapping-picklist", - "version": "0.3.5", + "version": "0.4.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "rest-data-mapping-picklist", - "version": "0.3.5", + "version": "0.4.0", "license": "ISC", "dependencies": { "axios": "^0.24.0", diff --git a/package.json b/package.json index 73939f9..0e2529d 100644 --- a/package.json +++ b/package.json @@ -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": { diff --git a/src/RestServiceData.ts b/src/RestServiceData.ts index 62c98b6..1c1113a 100644 --- a/src/RestServiceData.ts +++ b/src/RestServiceData.ts @@ -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); diff --git a/src/parameter-replacement.ts b/src/parameter-replacement.ts index 0e6d55f..a727749 100644 --- a/src/parameter-replacement.ts +++ b/src/parameter-replacement.ts @@ -10,8 +10,15 @@ export async function ReplaceFieldParameters(hasFields:string) : Promise 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, ""); }