Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(shared): keep Khmer and other Unicode 17 conjuncts intact in thread titles #48202

Opensaphid(GitHub profile, opens in a new tab)wants to merge 1 commit intomain fromrefs/pull/48202/headopened View on GitHub

Showing 3 changed files with 41 additions and 5 deletions.

x
0 of 3 viewed, 3 left
10 additions and 0 deletionspackages/shared/src/String.test.tsModified
View file
@@ -38,6 +38,16 @@
expect(truncate("Go क्\u200cष notes", 6)).toBe("Go क्\u200c...");
});
​
+ it("keeps Unicode 17 conjuncts whole at the title cutoff", () => {
+ const prefix = "a".repeat(47);
+ for (const conjunct of ["ក្ក", "က္က", "ᩈ᩠ᩈ", "ᬓ᭄ᬓ", "ꦏ꧀ꦏ", "𑼒𑽂𑼒"]) {
+ expect(truncate(`${prefix} ${conjunct} additional text`), conjunct).toBe(`${prefix}...`);
+ expect(truncate(`${prefix.slice(1)} ${conjunct} additional text`)).toBe(
+ `${prefix.slice(1)} ${conjunct}...`,
+ );
+ }
+ });
+​
it("keeps Thai and Lao AM vowels with their consonant", () => {
expect(truncate("Go \u0e01\u0e33 notes", 4)).toBe("Go...");
expect(truncate("Go \u0e81\u0eb3 notes", 4)).toBe("Go...");
9 additions and 5 deletionspackages/shared/src/String.tsModified
View file
@@ -6,10 +6,11 @@
/[\u0600-\u0605\u06DD\u070F\u0890\u0891\u08E2\u0D4E\u{110BD}\u{110CD}\u{111C2}\u{111C3}\u{113D1}\u{1193F}\u{11941}\u{11A84}-\u{11A89}\u{11D46}\u{11F02}]/u;
const CONTROL = /^(?:[\p{Cc}\p{Zl}\p{Zp}\p{Cf}]|(?=\p{Cn})\p{Default_Ignorable_Code_Point})$/u;
const ZWJ = "\u200d";
-// UAX #29 GB9c: an Indic consonant after a virama joins the previous consonant's cluster.
-const CONJUNCT_LINKER = /[\u094D\u09CD\u0ACD\u0B4D\u0C4D\u0D4D]/u;
+// UAX #29 GB9c: Linker and Consonant come from Unicode 17.0 DerivedCoreProperties.txt.
+const CONJUNCT_LINKER =
+ /[\u094D\u09CD\u0ACD\u0B4D\u0C4D\u0D4D\u1039\u17D2\u1A60\u1B44\u1BAB\uA9C0\uAAF6\u{10A3F}\u{11133}\u{113D0}\u{1193E}\u{11A47}\u{11A99}\u{11F42}]/u;