mirror of
https://github.com/vitorpamplona/amethyst.git
synced 2026-08-10 00:16:59 +00:00
RichTextParser.fixMissingSpaces used a Regex of the form `([^ \n])?(urls)([^ \n])?` to insert spaces around URLs glued to neighbouring text. Kotlin/Native's regex engine fails to backtrack the optional `([^ \n])?` capture groups to zero width, so on iOS every URL was corrupted (e.g. "https://x" became "h https://x"). That broke the downstream segmenter, which is why :commons:iosSimulatorArm64Test reported 19 failures across the RichText/Gallery/Pdf/F4a parsers once the test binary finally linked. Replace the regex with a direct left-to-right scan that inserts a single space wherever a detected URL touches a non-space/non-newline neighbour. The scan is engine-independent, so it behaves identically on JVM and Native. Verified equivalent to the old behaviour across the full commons richtext JVM corpus, and the new FixMissingSpacesTest pins the cases on every target (including iosSimulatorArm64).