diff --git a/frontend/__tests__/hooks/use-terminal.test.tsx b/frontend/__tests__/hooks/use-terminal.test.tsx index 4a90b56db20..aec9633d3a5 100644 --- a/frontend/__tests__/hooks/use-terminal.test.tsx +++ b/frontend/__tests__/hooks/use-terminal.test.tsx @@ -73,7 +73,7 @@ describe("useTerminal", () => { const anotherSecret = "super_secret_another_token"; const commands: Command[] = [ { - content: `export GITHUB_TOKEN=${secret},${anotherSecret}`, + content: `export GITHUB_TOKEN=${secret},${anotherSecret},${secret}`, type: "input", }, { content: secret, type: "output" }, @@ -94,7 +94,7 @@ describe("useTerminal", () => { // on the test order expect(mockTerminal.writeln).toHaveBeenNthCalledWith( 3, - `export GITHUB_TOKEN=${"*".repeat(10)},${"*".repeat(10)}`, + `export GITHUB_TOKEN=${"*".repeat(10)},${"*".repeat(10)},${"*".repeat(10)}`, ); expect(mockTerminal.writeln).toHaveBeenNthCalledWith(4, "*".repeat(10)); }); diff --git a/frontend/src/hooks/useTerminal.ts b/frontend/src/hooks/useTerminal.ts index 06bc993818b..b45618eeb17 100644 --- a/frontend/src/hooks/useTerminal.ts +++ b/frontend/src/hooks/useTerminal.ts @@ -137,10 +137,9 @@ export const useTerminal = ( // eslint-disable-next-line prefer-const let { content, type } = commands[i]; - if (secrets.length > 0) { - const secretRegex = new RegExp(secrets.join("|"), "g"); - content = content.replace(secretRegex, "*".repeat(10)); - } + secrets.forEach((secret) => { + content = content.replaceAll(secret, "*".repeat(10)); + }); terminal.current?.writeln(parseTerminalOutput(content));