Skip to content

Commit 9e07fd7

Browse files
authored
fix: strip emoji from correlator names (#527)
Signed-off-by: andrew.hendry <andrew.hendry@mantalus.com>
1 parent cee1b8e commit 9e07fd7

File tree

6 files changed

+56
-8
lines changed

6 files changed

+56
-8
lines changed

dist/attachReleaseAssets/index.js

Lines changed: 8 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/downloadSyft/index.js

Lines changed: 8 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/runSyftAction/index.js

Lines changed: 8 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/github/SyftGithubAction.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import {
2020
getClient,
2121
} from "./GithubClient";
2222
import { downloadSyftFromZip } from "./SyftDownloader";
23-
import { stringify } from "./Util";
23+
import { stringify, stripEmojis } from "./Util";
2424

2525
export const SYFT_BINARY_NAME = "syft";
2626
export const SYFT_VERSION = core.getInput("syft-version") || VERSION;
@@ -462,7 +462,9 @@ export async function uploadDependencySnapshot(): Promise<void> {
462462

463463
// Need to add the job and repo details
464464
snapshot.job = {
465-
correlator: core.getInput("dependency-snapshot-correlator") || correlator,
465+
correlator: stripEmojis(
466+
core.getInput("dependency-snapshot-correlator") || correlator
467+
),
466468
id: `${runId}`,
467469
};
468470
snapshot.sha = sha;

src/github/Util.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,10 @@ import s from "fast-safe-stringify";
33
export function stringify(o: any): string {
44
return s(o, undefined, 2);
55
}
6+
7+
export function stripEmojis(text: string): string {
8+
// Regular expression to match emojis
9+
const emojiRegex =
10+
/(?:[\u2700-\u27BF]|[\uE000-\uF8FF]|[\uD83C-\uDBFF][\uDC00-\uDFFF]|\ud83d[\udc00-\ude4f\ude80-\udeff]|\ud83e[\udd10-\udd3f\udd40-\uddff])/g;
11+
return text.replace(emojiRegex, "");
12+
}

tests/Util.test.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import { stripEmojis } from "../src/github/Util";
2+
3+
describe("stripEmojis", () => {
4+
it("Should not modify strings without emojis", () => {
5+
const input = "Workflow for building my awesome app";
6+
const output = stripEmojis(input);
7+
expect(output).toBe(input);
8+
});
9+
10+
it("should remove single emojis from strings", () => {
11+
const input = "Workflow for building my awesome app🏗";
12+
const output = stripEmojis(input);
13+
expect(output).toBe("Workflow for building my awesome app");
14+
});
15+
16+
it("should remove multiple emojis from strings", () => {
17+
const input = "🚀Good 🧹morning 🏗!";
18+
const output = stripEmojis(input);
19+
expect(output).toBe("Good morning !");
20+
});
21+
});

0 commit comments

Comments
 (0)