Skip to content

Commit

Permalink
Update search
Browse files Browse the repository at this point in the history
  • Loading branch information
amanape committed Oct 28, 2024
1 parent 5781f79 commit 048cef9
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
4 changes: 2 additions & 2 deletions frontend/__tests__/hooks/use-terminal.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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" },
Expand All @@ -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));
});
Expand Down
7 changes: 3 additions & 4 deletions frontend/src/hooks/useTerminal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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));

Expand Down

0 comments on commit 048cef9

Please sign in to comment.