Skip to content

Commit

Permalink
Fix trailing slash issue (#2137)
Browse files Browse the repository at this point in the history
* fix trailing slash

* fix the replace

* handle edge cases

* remove log
  • Loading branch information
harunrst committed Mar 24, 2023
1 parent ef9ff61 commit 76d5918
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/models/console/consoleOperation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,11 +110,14 @@ 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()}}`;

if (requestUrl.indexOf(parameterPlaceholder) > -1) {
requestUrl = requestUrl.replace(parameterPlaceholder,
Expand All @@ -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}`;
}
Expand Down

0 comments on commit 76d5918

Please sign in to comment.