Skip to content

Commit 1b043a8

Browse files
committed
fix(utils): si un texte produit par IA finit par la marque de fin d'une balise ">", on considère que cela peut être la fin du texte produit
1 parent 1e6dea3 commit 1b043a8

4 files changed

Lines changed: 8 additions & 3 deletions

File tree

app/js/utils/strings.mjs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,11 @@ export function tryConvertStringToNumber(input) {
1616
}
1717
}
1818

19+
// Pour vérifier si une chaîne de caractère se termine par un signe qui marque la fin d'un texte.
1920
export function hasSentenceEndMark(str) {
2021
const trimmed = str.trim();
2122
const lastChar = trimmed.slice(-1);
22-
return [".", "!", "?", "…"].includes(lastChar);
23+
return [".", "!", "?", "…", ">"].includes(lastChar);
2324
}
2425

2526
export function sanitizeHtml(html, allowedTags) {

app/script.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/script.min.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/unit/utils/strings.spec.mjs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,10 @@ describe("hasSentenceEndMark", () => {
186186
expect(hasSentenceEndMark("To be continued…")).toBe(true);
187187
});
188188

189+
it("returns true when the string ends with the end of a HTML tag mark >", () => {
190+
expect(hasSentenceEndMark("<code>Test</code>")).toBe(true);
191+
});
192+
189193
it("returns false when the string ends with a semicolon", () => {
190194
expect(hasSentenceEndMark("Wait here;")).toBe(false);
191195
});

0 commit comments

Comments
 (0)