Skip to content

Commit

Permalink
DEVPROD-7624: Escape task name in getTaskHistoryRoute (#170)
Browse files Browse the repository at this point in the history
  • Loading branch information
SupaJoon authored Jun 13, 2024
1 parent 6f82674 commit 69761b5
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
7 changes: 7 additions & 0 deletions apps/spruce/src/constants/routes.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ import {

const identifierWithSpecialCharacters = "!?identifier@";
const escapedIdentifier = "!%3Fidentifier%40";
const taskIDWithSpecialCharacters = "bazel_run_/@!:/:format";
const escapedTaskID = "bazel_run_%2F%40!%3A%2F%3Aformat";

describe("getProjectPatchesRoute", () => {
it("escapes special characters projectIdentifier", () => {
Expand Down Expand Up @@ -131,6 +133,11 @@ describe("getTaskHistoryRoute", () => {
getTaskHistoryRoute(identifierWithSpecialCharacters, "someTaskId"),
).toBe(`/task-history/${escapedIdentifier}/someTaskId`);
});
it("escapes special characters taskId", () => {
expect(
getTaskHistoryRoute("someProject", taskIDWithSpecialCharacters),
).toBe(`/task-history/someProject/${escapedTaskID}`);
});
it("generates a link with failing or passing tests", () => {
expect(
getTaskHistoryRoute("someProject", "someTaskId", {
Expand Down
2 changes: 1 addition & 1 deletion apps/spruce/src/constants/routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ export const getTaskHistoryRoute = (
const { filters, selectedCommit, visibleColumns } = options || {};

return getHistoryRoute(
`${paths.taskHistory}/${encodeURIComponent(projectIdentifier)}/${taskName}`,
`${paths.taskHistory}/${encodeURIComponent(projectIdentifier)}/${encodeURIComponent(taskName)}`,
filters,
selectedCommit,
visibleColumns,
Expand Down

0 comments on commit 69761b5

Please sign in to comment.