From 2eacae3ca358d179c053e9e741fb67cb3591473b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Harun=20Re=C5=9Fit?= Date: Thu, 23 Mar 2023 14:43:25 +0100 Subject: [PATCH 1/4] fix trailing slash --- src/models/console/consoleOperation.ts | 2 +- src/models/operation.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/models/console/consoleOperation.ts b/src/models/console/consoleOperation.ts index 0536b2b18..62e5ee5aa 100644 --- a/src/models/console/consoleOperation.ts +++ b/src/models/console/consoleOperation.ts @@ -132,7 +132,7 @@ export class ConsoleOperation { if (this.api.apiVersionSet && this.api.apiVersionSet.versioningScheme === "Query") { requestUrl = this.addParam(requestUrl, this.api.apiVersionSet.versionQueryName, this.api.apiVersion); } - requestUrl = requestUrl.replace("/*", ""); + requestUrl = requestUrl.replace("/*", "/"); return `${this.api.path}${versionPath}${requestUrl}`; } diff --git a/src/models/operation.ts b/src/models/operation.ts index 984545bc1..f7894df7c 100644 --- a/src/models/operation.ts +++ b/src/models/operation.ts @@ -54,6 +54,6 @@ export class Operation { }) .join(""); - this.displayUrlTemplate = `${this.urlTemplate.replace("/*", "")}${optionalQueryParameters}`; + this.displayUrlTemplate = `${this.urlTemplate.replace("/*", "/")}${optionalQueryParameters}`; } } \ No newline at end of file From cbc553134954d6137f0ec8c71d06bd0261a69792 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Harun=20Re=C5=9Fit?= Date: Thu, 23 Mar 2023 14:45:06 +0100 Subject: [PATCH 2/4] fix the replace --- src/models/console/consoleOperation.ts | 2 +- src/models/operation.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/models/console/consoleOperation.ts b/src/models/console/consoleOperation.ts index 62e5ee5aa..808aee3c4 100644 --- a/src/models/console/consoleOperation.ts +++ b/src/models/console/consoleOperation.ts @@ -132,7 +132,7 @@ export class ConsoleOperation { if (this.api.apiVersionSet && this.api.apiVersionSet.versioningScheme === "Query") { requestUrl = this.addParam(requestUrl, this.api.apiVersionSet.versionQueryName, this.api.apiVersion); } - requestUrl = requestUrl.replace("/*", "/"); + requestUrl = requestUrl.replace("*", ""); return `${this.api.path}${versionPath}${requestUrl}`; } diff --git a/src/models/operation.ts b/src/models/operation.ts index f7894df7c..39ba2529a 100644 --- a/src/models/operation.ts +++ b/src/models/operation.ts @@ -54,6 +54,6 @@ export class Operation { }) .join(""); - this.displayUrlTemplate = `${this.urlTemplate.replace("/*", "/")}${optionalQueryParameters}`; + this.displayUrlTemplate = `${this.urlTemplate.replace("*", "")}${optionalQueryParameters}`; } } \ No newline at end of file From fb8d59d800e4dd3f52e52ecacd62a8bd43a1dd06 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Harun=20Re=C5=9Fit?= Date: Thu, 23 Mar 2023 17:56:53 +0100 Subject: [PATCH 3/4] handle edge cases --- src/models/console/consoleOperation.ts | 12 ++++++++---- src/models/operation.ts | 2 +- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/models/console/consoleOperation.ts b/src/models/console/consoleOperation.ts index 808aee3c4..60728242b 100644 --- a/src/models/console/consoleOperation.ts +++ b/src/models/console/consoleOperation.ts @@ -110,12 +110,15 @@ export class ConsoleOperation { } let requestUrl = this.urlTemplate; - const parameters = this.templateParameters().concat(this.request.queryParameters()); + let parameters = this.templateParameters().concat(this.request.queryParameters()); + + const wildcardName = "{*}" + requestUrl = requestUrl.replace("*", wildcardName); parameters.forEach(parameter => { if (parameter.value()) { - const parameterPlaceholder = parameter.name() !== "*" ? `{${parameter.name()}}` : "*"; - + const parameterPlaceholder = `{${parameter.name()}}`; + console.log(parameterPlaceholder) if (requestUrl.indexOf(parameterPlaceholder) > -1) { requestUrl = requestUrl.replace(parameterPlaceholder, !getHidden || !parameter.secret ? Utils.encodeURICustomized(parameter.value()) @@ -132,7 +135,8 @@ export class ConsoleOperation { if (this.api.apiVersionSet && this.api.apiVersionSet.versioningScheme === "Query") { requestUrl = this.addParam(requestUrl, this.api.apiVersionSet.versionQueryName, this.api.apiVersion); } - requestUrl = requestUrl.replace("*", ""); + + requestUrl = requestUrl.replace(wildcardName, ""); return `${this.api.path}${versionPath}${requestUrl}`; } diff --git a/src/models/operation.ts b/src/models/operation.ts index 39ba2529a..984545bc1 100644 --- a/src/models/operation.ts +++ b/src/models/operation.ts @@ -54,6 +54,6 @@ export class Operation { }) .join(""); - this.displayUrlTemplate = `${this.urlTemplate.replace("*", "")}${optionalQueryParameters}`; + this.displayUrlTemplate = `${this.urlTemplate.replace("/*", "")}${optionalQueryParameters}`; } } \ No newline at end of file From 5d961896b20b6cb5794a127e5402c757ec7ec26d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Harun=20Re=C5=9Fit?= Date: Thu, 23 Mar 2023 17:57:46 +0100 Subject: [PATCH 4/4] remove log --- src/models/console/consoleOperation.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/models/console/consoleOperation.ts b/src/models/console/consoleOperation.ts index 60728242b..647374490 100644 --- a/src/models/console/consoleOperation.ts +++ b/src/models/console/consoleOperation.ts @@ -118,7 +118,7 @@ export class ConsoleOperation { parameters.forEach(parameter => { if (parameter.value()) { const parameterPlaceholder = `{${parameter.name()}}`; - console.log(parameterPlaceholder) + if (requestUrl.indexOf(parameterPlaceholder) > -1) { requestUrl = requestUrl.replace(parameterPlaceholder, !getHidden || !parameter.secret ? Utils.encodeURICustomized(parameter.value())