From b2c6f3df95a207d3c196fc9db54ac1768abf350f Mon Sep 17 00:00:00 2001 From: tanhakabir Date: Mon, 17 May 2021 13:00:39 -0700 Subject: [PATCH] Fixed variables embedded in text for parameters and fields (#96) * fill in variables that only fill in part of field * fix debt * fix cleaning response from secret values --- out/common/request.d.ts | 1 + out/common/request.js | 31 ++++++++++++++++++++++++++----- out/common/request.js.map | 2 +- src/common/request.ts | 30 +++++++++++++++++++++++++----- src/extension/languageProvider.ts | 2 +- 5 files changed, 54 insertions(+), 12 deletions(-) diff --git a/out/common/request.d.ts b/out/common/request.d.ts index e513a1d..dc7a1cf 100644 --- a/out/common/request.d.ts +++ b/out/common/request.d.ts @@ -39,4 +39,5 @@ export declare class RequestParser { private _parseBody; private _attemptToLoadFile; private _attemptToLoadVariable; + private _getEndOfWordIndex; } diff --git a/out/common/request.js b/out/common/request.js index 8f4e4e3..26ef84f 100644 --- a/out/common/request.js +++ b/out/common/request.js @@ -210,22 +210,43 @@ export class RequestParser { return; } _attemptToLoadVariable(text) { - if (!text.startsWith('$')) { + let indexOfDollarSign = text.indexOf('$'); + if (indexOfDollarSign === -1) { return text; } - let loadedFromVariable = cache.attemptToLoadVariable(text.substring(1)); + let beforeVariable = text.substr(0, indexOfDollarSign); + let indexOfEndOfPossibleVariable = this._getEndOfWordIndex(text, indexOfDollarSign); + let possibleVariable = text.substr(indexOfDollarSign + 1, indexOfEndOfPossibleVariable); + let loadedFromVariable = cache.attemptToLoadVariable(possibleVariable); if (loadedFromVariable) { if (typeof loadedFromVariable === 'string') { - if (text.startsWith('$SECRETS')) { + if (possibleVariable.startsWith('SECRETS')) { this.valuesReplacedBySecrets.push(loadedFromVariable); } - return loadedFromVariable; + return beforeVariable + loadedFromVariable; } else { - return stringify(loadedFromVariable); + return beforeVariable + stringify(loadedFromVariable); } } return text; } + _getEndOfWordIndex(text, startingIndex) { + let indexOfSpace = text.indexOf(' ', startingIndex !== null && startingIndex !== void 0 ? startingIndex : 0); + let indexOfComma = text.indexOf(',', startingIndex !== null && startingIndex !== void 0 ? startingIndex : 0); + let indexOfSemicolon = text.indexOf(';', startingIndex !== null && startingIndex !== void 0 ? startingIndex : 0); + let indexOfEnd = text.length - 1; + let values = []; + if (indexOfSpace !== -1) { + values.push(indexOfSpace); + } + if (indexOfComma !== -1) { + values.push(indexOfComma); + } + if (indexOfSemicolon !== -1) { + values.push(indexOfSemicolon); + } + return Math.min(...values, indexOfEnd); + } } //# sourceMappingURL=request.js.map \ No newline at end of file diff --git a/out/common/request.js.map b/out/common/request.js.map index 53d9f3a..feb7ef5 100644 --- a/out/common/request.js.map +++ b/out/common/request.js.map @@ -1 +1 @@ -{"version":3,"file":"request.js","sourceRoot":"","sources":["../../src/common/request.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AACzB,MAAM,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC;AACnB,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AACzB,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,IAAI,SAAS,GAAG,OAAO,CAAC,qBAAqB,CAAC,CAAC;AAC/C,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAC;AACnD,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AACrD,OAAO,KAAK,MAAM,MAAM,QAAQ,CAAC;AACjC,OAAO,EAAE,MAAM,EAAsB,MAAM,iBAAiB,CAAC;AAC7D,OAAO,KAAK,KAAK,MAAM,SAAS,CAAC;AA0BjC,MAAM,OAAO,aAAa;IAOtB,YAAY,KAAa;;QAFjB,4BAAuB,GAAa,EAAE,CAAC;QAI3C,IAAI,cAAc,GAAG,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QAEtC,IAAI,cAAc,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAA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C;SAClB;QAAC,OAAO,CAAC,EAAE;YACR,OAAO,OAAO,CAAC;SAClB;IACL,CAAC;IAEO,kBAAkB,CAAC,gBAAwB;;QAC/C,IAAI;YACA,MAAM,YAAY,GAAG,IAAI,CAAC,OAAO,CAAC,MAAA,MAAA,MAAM,CAAC,MAAM,CAAC,gBAAgB,0CAAE,QAAQ,CAAC,GAAG,CAAC,MAAM,mCAAI,EAAE,CAAC,CAAC;YAC7F,IAAI,CAAC,YAAY,EAAE;gBAAE,OAAO;aAAE;YAE9B,MAAM,YAAY,GAAG,IAAI,CAAC,IAAI,CAAC,YAAY,EAAE,gBAAgB,CAAC,CAAC;YAC/D,OAAO,EAAE,CAAC,YAAY,CAAC,YAAY,CAAC,CAAC,QAAQ,EAAE,CAAC;SACnD;QAAC,OAAO,KAAK,EAAE;YACZ,qBAAqB;SACxB;QACD,OAAO;IACX,CAAC;IAEO,sBAAsB,CAAC,IAAY;QACvC,IAAG,CAAC,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE;YACtB,OAAO,IAAI,CAAC;SACf;QAED,IAAI,kBAAkB,GAAG,KAAK,CAAC,qBAAqB,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC;QACxE,IAAG,kBAAkB,EAAE;YACnB,IAAG,OAAO,kBAAkB,KAAK,QAAQ,EAAE;gBACvC,IAAG,IAAI,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE;oBAC5B,IAAI,CAAC,uBAAuB,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAC;iBACzD;gBACD,OAAO,kBAAkB,CAAC;aAC7B;iBAAM;gBACH,OAAO,SAAS,CAAC,kBAAkB,CAAC,CAAC;aACxC;SACJ;QAED,OAAO,IAAI,CAAC;IAChB,CAAC;CACJ"} \ No newline at end of file +{"version":3,"file":"request.js","sourceRoot":"","sources":["../../src/common/request.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AACzB,MAAM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aAAa,aAAb,aAAa,cAAb,aAAa,GAAI,CAAC,CAAC,CAAC;QAC7D,IAAI,UAAU,GAAG,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC;QAEjC,IAAI,MAAM,GAAa,EAAE,CAAC;QAE1B,IAAG,YAAY,KAAK,CAAC,CAAC,EAAE;YAAE,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;SAAE;QACtD,IAAG,YAAY,KAAK,CAAC,CAAC,EAAE;YAAE,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;SAAE;QACtD,IAAG,gBAAgB,KAAK,CAAC,CAAC,EAAE;YAAE,MAAM,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC;SAAE;QAE9D,OAAO,IAAI,CAAC,GAAG,CAAC,GAAI,MAAM,EAAE,UAAU,CAAC,CAAC;IAC5C,CAAC;CACJ"} \ No newline at end of file diff --git a/src/common/request.ts b/src/common/request.ts index 7761cb4..a9fbee7 100644 --- a/src/common/request.ts +++ b/src/common/request.ts @@ -269,22 +269,42 @@ export class RequestParser { } private _attemptToLoadVariable(text: string): string { - if(!text.startsWith('$')) { + let indexOfDollarSign = text.indexOf('$'); + if(indexOfDollarSign === -1) { return text; } - let loadedFromVariable = cache.attemptToLoadVariable(text.substring(1)); + let beforeVariable = text.substr(0, indexOfDollarSign); + + let indexOfEndOfPossibleVariable = this._getEndOfWordIndex(text, indexOfDollarSign); + let possibleVariable = text.substr(indexOfDollarSign + 1, indexOfEndOfPossibleVariable); + let loadedFromVariable = cache.attemptToLoadVariable(possibleVariable); if(loadedFromVariable) { if(typeof loadedFromVariable === 'string') { - if(text.startsWith('$SECRETS')) { + if(possibleVariable.startsWith('SECRETS')) { this.valuesReplacedBySecrets.push(loadedFromVariable); } - return loadedFromVariable; + return beforeVariable + loadedFromVariable; } else { - return stringify(loadedFromVariable); + return beforeVariable + stringify(loadedFromVariable); } } return text; } + + private _getEndOfWordIndex(text: string, startingIndex?: number): number { + let indexOfSpace = text.indexOf(' ', startingIndex ?? 0); + let indexOfComma = text.indexOf(',', startingIndex ?? 0); + let indexOfSemicolon = text.indexOf(';', startingIndex ?? 0); + let indexOfEnd = text.length - 1; + + let values: number[] = []; + + if(indexOfSpace !== -1) { values.push(indexOfSpace); } + if(indexOfComma !== -1) { values.push(indexOfComma); } + if(indexOfSemicolon !== -1) { values.push(indexOfSemicolon); } + + return Math.min(... values, indexOfEnd); + } } \ No newline at end of file diff --git a/src/extension/languageProvider.ts b/src/extension/languageProvider.ts index fcdeb36..232375b 100644 --- a/src/extension/languageProvider.ts +++ b/src/extension/languageProvider.ts @@ -93,7 +93,7 @@ export class VariableCompletionItemProvider implements vscode.CompletionItemProv const result: vscode.CompletionItem[] = []; let text = document.lineAt(position.line).text.substring(0, position.character); - let startingIndex = (text.lastIndexOf(' ') > text.lastIndexOf('=') ? text.lastIndexOf(' ') : text.lastIndexOf('=')) + 1; + let startingIndex = Math.max(text.lastIndexOf(' '), text.lastIndexOf('=')) + 1; let varName = text.substring(startingIndex).trim(); const tokens: string[] = varName.split('.').filter(Boolean).map(s => s.replace('.', ''));