Skip to content

Commit

Permalink
Encode all components in the url
Browse files Browse the repository at this point in the history
Signed-off-by: Andrew Shirley <andrew.shirley@sainsburys.co.uk>
Signed-off-by: blam <ben@blam.sh>
  • Loading branch information
ashirley authored and benjdlambert committed Jul 14, 2021
1 parent b240ef7 commit 24d786e
Showing 1 changed file with 17 additions and 11 deletions.
28 changes: 17 additions & 11 deletions plugins/jenkins/src/api/JenkinsApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,11 @@ export class JenkinsClient implements JenkinsApi {
filter: { branch?: string },
): Promise<Project[]> {
const url = new URL(
`${await this.discoveryApi.getBaseUrl('jenkins')}/v1/entity/${
entity.namespace
}/${entity.kind}/${entity.name}/projects`,
`${await this.discoveryApi.getBaseUrl(
'jenkins',
)}/v1/entity/${encodeURIComponent(entity.namespace)}/${encodeURIComponent(
entity.kind,
)}/${encodeURIComponent(entity.name)}/projects`,
);

if (filter.branch) {
Expand Down Expand Up @@ -158,11 +160,13 @@ export class JenkinsClient implements JenkinsApi {
jobName: string,
buildNumber: string,
): Promise<Build> {
const url = `${await this.discoveryApi.getBaseUrl('jenkins')}/v1/entity/${
entity.namespace
}/${entity.kind}/${entity.name}/job/${encodeURIComponent(
const url = `${await this.discoveryApi.getBaseUrl(
'jenkins',
)}/v1/entity/${encodeURIComponent(entity.namespace)}/${encodeURIComponent(
entity.kind,
)}/${encodeURIComponent(entity.name)}/job/${encodeURIComponent(
jobName,
)}/${buildNumber}`;
)}/${encodeURIComponent(buildNumber)}`;

const idToken = await this.identityApi.getIdToken();
const response = await fetch(url, {
Expand All @@ -180,11 +184,13 @@ export class JenkinsClient implements JenkinsApi {
jobName: string,
buildNumber: string,
): Promise<void> {
const url = `${await this.discoveryApi.getBaseUrl('jenkins')}/v1/entity/${
entity.namespace
}/${entity.kind}/${entity.name}/job/${encodeURIComponent(
const url = `${await this.discoveryApi.getBaseUrl(
'jenkins',
)}/v1/entity/${encodeURIComponent(entity.namespace)}/${encodeURIComponent(
entity.kind,
)}/${encodeURIComponent(entity.name)}/job/${encodeURIComponent(
jobName,
)}/${buildNumber}:rebuild`;
)}/${encodeURIComponent(buildNumber)}:rebuild`;

const idToken = await this.identityApi.getIdToken();
await fetch(url, {
Expand Down

0 comments on commit 24d786e

Please sign in to comment.