Skip to content

Commit

Permalink
🐞 fix(mapper): fixed regex string extractor
Browse files Browse the repository at this point in the history
  • Loading branch information
andrii-bohdan committed Jan 7, 2024
1 parent 13dd482 commit 490d610
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/app/utils/mapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@ import { Commit } from "../../commons/typings/settings";
import { getEmojiSettings } from "./settings";

export function extractString(str: string | undefined): string {
const regex = /[\p{L}\p{N}\s]+/u;
const regex = /[\u0020-\u007e\u00a0-\u00ff\u0152\u0153\u0178]+/gu;
const matches = str?.match(regex);

if (matches && matches.length > 0) {
return matches[0].trim();
}

return "";
}

Expand Down Expand Up @@ -39,12 +41,15 @@ export const templateSerializer = (template: string, data: Commit[]) => {
const showEmojis = getEmojiSettings();
for (let i = 0; i < data.length; i++) {
const e = data[i];

if (!showEmojis) {
e.value = extractString(e.value);
}

if (e.key === "scope" && e.value === "") {
newTemplate = newTemplate.replace(`({${e.key}})`, "");
}

newTemplate = newTemplate.replace(`{${e.key}}`, e.value);
}

Expand Down

0 comments on commit 490d610

Please sign in to comment.