Skip to content

Commit

Permalink
Fixed template generation of URLs with template parameters. (#497)
Browse files Browse the repository at this point in the history
  • Loading branch information
azaslonov authored Feb 19, 2020
1 parent 1ef837a commit 62f4337
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions src/models/console/consoleOperation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ export class ConsoleOperation {

private getRequestPath(): string {
let versionPath = "";
const revision = "";

if (this.api.apiVersionSet && this.api.apiVersion && this.api.apiVersionSet.versioningScheme === "Segment") {
versionPath = `/${this.api.apiVersion}`;
Expand All @@ -86,15 +85,13 @@ export class ConsoleOperation {

parameters.forEach(parameter => {
if (parameter.value()) {
const parameterPlaceholder = `{${parameter.name}}`;
const parameterName = encodeURIComponent(parameter.name());
const parameterValue = encodeURIComponent(parameter.value());
const parameterPlaceholder = parameter.name() !== "*" ? `{${parameter.name()}}` : "*";

if (requestUrl.indexOf(parameterPlaceholder) > -1) {
requestUrl = requestUrl.replace(parameterPlaceholder, parameterValue);
requestUrl = requestUrl.replace(parameterPlaceholder, encodeURI(parameter.value()));
}
else {
requestUrl = this.addParam(requestUrl, parameterName, parameterValue);
requestUrl = this.addParam(requestUrl, encodeURI(parameter.name()), encodeURI(parameter.value()));
}
}
});
Expand All @@ -103,7 +100,7 @@ export class ConsoleOperation {
requestUrl = this.addParam(requestUrl, this.api.apiVersionSet.versionQueryName, this.api.apiVersion);
}

return `${this.api.path}${versionPath}${revision}${requestUrl}`;
return `${this.api.path}${versionPath}${requestUrl}`;
}

}

0 comments on commit 62f4337

Please sign in to comment.