* test(#2848): add failing-first regression for non-Latin slug transliteration generateSlugInternal and slugify both strip non-ASCII chars with no transliteration step, so an all-Cyrillic title reduces to an empty slug. 12-row matrix: Cyrillic regression (both impls), Latin negative control, multi-letter mappings, soft/hard sign drops, Ukrainian extras, null contract, CJK unaffected, mixed scripts, truncation parity, slugify's distinct no-truncate contract. * fix(#2848): transliterate Cyrillic titles to ASCII before slug strip Both generateSlugInternal (src/core-utils.cts) and slugify (src/gsd2-import.cts) stripped non-ASCII with no transliteration, so an all-Cyrillic title reduced to an empty slug, producing unnamed phase directories (01-) and empty milestone_slug init JSON. Add a shared transliterateForSlug primitive (core-utils) covering Russian + the reported Ukrainian/Belarusian extras (і ї є ґ ў), with multi-letter mappings (ж→zh ч→ch ш→sh щ→sch ю→yu я→ya) and dropped soft/hard signs (ъ ь). It runs BEFORE the existing ASCII filter, so Latin-script text hits zero map entries and is byte-for-byte unchanged (negative control). slugify consumes the shared primitive, preserving its distinct single hyphen-strip + no-truncation contract. CJK/unmapped scripts keep the existing strip-to-ASCII behavior. Also corrects two test assertions to match the chosen й→y mapping and the б→b (not bie) transliteration. * changeset(#2848): Fixed — non-Latin slug transliteration * changeset(#2848): backfill PR number 2934 --------- Co-authored-by: sim <sim@local>
This commit is contained in:
@@ -262,6 +262,33 @@ describe('slugify', () => {
|
||||
test('strips leading/trailing hyphens', () => {
|
||||
assert.strictEqual(slugify(' spaces '), 'spaces');
|
||||
});
|
||||
|
||||
// ─── #2848: non-Latin (Cyrillic) titles must not produce an empty slug. The
|
||||
// transliteration map (shared with generateSlugInternal) is applied before the
|
||||
// ASCII filter. slugify keeps its DISTINCT contract: single leading/trailing
|
||||
// hyphen strip, NO truncation.
|
||||
|
||||
test('#2848 row 2 — Cyrillic title produces a non-empty transliterated slug', () => {
|
||||
const result = slugify('Настройка окружения');
|
||||
assert.ok(typeof result === 'string' && result.length > 0, `Cyrillic title must not produce an empty slug; got: ${JSON.stringify(result)}`);
|
||||
assert.ok(/^[a-z0-9]+(-[a-z0-9]+)*$/.test(result), `slug must be ASCII-only and well-formed; got: ${result}`);
|
||||
assert.strictEqual(result, 'nastroyka-okruzheniya');
|
||||
});
|
||||
|
||||
test('#2848 row 3 — Latin-script output is byte-for-byte unchanged (negative control)', () => {
|
||||
assert.strictEqual(slugify('Auth System'), 'auth-system');
|
||||
assert.strictEqual(slugify('My Feature (v2)'), 'my-feature-v2');
|
||||
assert.strictEqual(slugify(' spaces '), 'spaces');
|
||||
});
|
||||
|
||||
test('#2848 row 11 — slugify does NOT truncate (distinct from generateSlugInternal contract)', () => {
|
||||
// generateSlugInternal truncates at 60; slugify must NOT — that difference is
|
||||
// existing, documented behavior, not the bug. A long Cyrillic title produces a
|
||||
// long ASCII slug that exceeds 60 chars.
|
||||
const long = 'Настройка'.repeat(20);
|
||||
const result = slugify(long);
|
||||
assert.ok(result.length > 60, `slugify must not truncate; got len ${result.length}`);
|
||||
});
|
||||
});
|
||||
|
||||
describe('zeroPad', () => {
|
||||
|
||||
Reference in New Issue
Block a user