Files
poli0981andClaude Opus 5.5 999d0887ee Fix the SonarQube Cloud findings; release 4.4.2 (#155)
The first SonarQube Cloud scan reported 57 issues. 45 are fixed in code, the 11 on the saved itch.io test pages leave the scan via .sonarcloud.properties, and css:S8776 (Tailwind's @utility nesting) is a false positive to mark on SonarQube Cloud.

Worker: trailing slashes and the gate cookie's padding are trimmed by trimEnd() instead of /\/+$/ (quadratic on the public 404 path); the feed and collection parsers lose their backtracking regexes; compareCodeUnits keeps the code-unit sorts (the rule's localeCompare is locale-dependent); Number.*, DEFAULT_SIZES, crypto.randomUUID; i18n-edit.mjs reads stdin. Pipeline: the NSFW notices are one selector list, either class (the rule's ".a.b" would need both), each tested; plain if-guards; update_info.main returns None; no plain-http adapter; [[ ]] in cf_build_status.sh.

Supply chain: requirements*.txt are hash-locked pip-tools compiles of requirements*.in (on Python 3.14, which Dependabot reads from the header), installed with --require-hashes --only-binary :all: in block scalars; npm ci --ignore-scripts in CI and the release builds (verified by manual release runs on all platforms); npm run cf:check.

Release 4.4.2: also ships the toolchain upgrade (#149, #154) and Dependabot #141-#148, #150, #152, #153. CLAUDE.md gotchas 40 and 41.

[skip-discuss]

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-22 18:16:12 +07:00

41 lines
1.2 KiB
TypeScript

import { describe, expect, it } from 'vitest'
import { compareCodeUnits, decodeEntities, trimEnd } from './text'
describe('decodeEntities', () => {
it('decodes decimal, hex and named references', () => {
expect(decodeEntities('&#65;&#x42;&#X43; &lt;b&gt; Rock &amp; Roll&nbsp;')).toBe('ABC <b> Rock & Roll')
})
})
describe('trimEnd', () => {
it.each([
['/games/', '/', '/games'],
['/games///', '/', '/games'],
['/games', '/', '/games'],
['///', '/', ''],
['', '/', ''],
['c2lnbg==', '=', 'c2lnbg'],
])('%j without trailing %j', (text, char, expected) => {
expect(trimEnd(text, char)).toBe(expected)
})
it('takes linear time on a long run that is not at the end (a /\\/+$/ regex did not)', () => {
const path = `/${'/'.repeat(200_000)}x`
expect(trimEnd(path, '/')).toBe(path)
})
})
describe('compareCodeUnits', () => {
it('orders like a bare sort(): code units, not the locale', () => {
expect(['game_info_010.json', 'alpha', 'game_info_002.json', 'Zeta', 'b', 'B'].sort(compareCodeUnits)).toEqual([
'B',
'Zeta',
'alpha',
'b',
'game_info_002.json',
'game_info_010.json',
])
expect(compareCodeUnits('same', 'same')).toBe(0)
})
})