aso: App Store keyword fill hint and limit both count UTF-8 bytes (non-Latin locales were warned to add characters that would break the 100-byte limit)

This commit is contained in:
CRTkafa 2026-10-11 18:14:27 +00:00
parent 43daeef97f
commit 41b92dfa13
2 changed files with 14 additions and 4 deletions

View file

@ -27,10 +27,12 @@ export function auditAppleKeywords(locale: string, c: AppleCopy, appName: string
const at = `apple ${locale}`;
const kw = c.keywords ?? '';
if (!kw) return [{ level: 'error', where: at, msg: 'keywords: empty' }];
const chars = len(kw);
if (chars > 100) out.push({ level: 'error', where: at, msg: `keywords: ${chars} characters > 100` });
// App Store Connect limits the keyword field to 100 bytes (UTF-8), not characters: Cyrillic, Arabic, Hindi, Thai,
// Japanese, Korean and Chinese words take 2-3 bytes per character, so both the limit and the fill hint count bytes.
const bytes = Buffer.byteLength(kw, 'utf8');
if (bytes > 100) out.push({ level: 'error', where: at, msg: `keywords: ${bytes} bytes > 100` });
if (/,\s|\s,/.test(kw)) out.push({ level: 'error', where: at, msg: 'keywords: spaces around commas waste characters' });
if (chars < 90) out.push({ level: 'warn', where: at, msg: `keywords: ${chars}/100 used; fill at least 90 (${100 - chars} characters free)` });
if (bytes < 90) out.push({ level: 'warn', where: at, msg: `keywords: ${bytes}/100 bytes used; fill at least 90 (${100 - bytes} bytes free)` });
const terms = kw.split(',').map(t => t.trim().toLocaleLowerCase(locale)).filter(Boolean);
const seen = new Set<string>();
for (const t of terms) {

View file

@ -148,10 +148,18 @@ describe('mcp: screenshot and video tools', () => {
});
describe('aso', () => {
test('App Store keywords count bytes, not characters (limit and fill hint)', () => {
const msgs = (kw: string) => auditAppleKeywords('ru', { keywords: kw } as never, 'X').map(f => f.msg);
const short = 'игра,бег,прыжки,монеты,уровни,рекорд,аркада'; // 43 characters, 80 bytes
expect(msgs(short).some(m => m.includes('80/100 bytes') && m.includes('fill at least 90'))).toBe(true);
const full = short + ',быстро'; // 50 characters but 93 bytes: full enough
expect(msgs(full).some(m => m.includes('fill at least 90'))).toBe(false);
expect(msgs(full + ',звук').some(m => m.includes('102 bytes > 100'))).toBe(true);
});
test('keyword field rules', () => {
const f = auditAppleKeywords('en-US', { subtitle: 'Relaxing puzzle', keywords: 'match,puzzle,match,free game' }, 'Tile Match');
const text = f.map(x => `${x.level}:${x.msg}`).join('\n');
expect(text).toContain('warn:keywords: 28/100 used');
expect(text).toContain('warn:keywords: 28/100 bytes used');
expect(text).toContain('"match" listed twice');
expect(text).toContain('repeat words from the name / subtitle (already indexed): match, puzzle');
expect(text).toContain('filler words that rarely help: free, game');