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>
30 lines
1.0 KiB
TypeScript
30 lines
1.0 KiB
TypeScript
/** The HTML/XML character references itch.io pages and feeds use, decoded. */
|
|
export function decodeEntities(text: string): string {
|
|
return text
|
|
.replace(/&#(\d+);/g, (_, n: string) => String.fromCodePoint(Number(n)))
|
|
.replace(/&#x([0-9a-f]+);/gi, (_, n: string) => String.fromCodePoint(Number.parseInt(n, 16)))
|
|
.replace(/"/g, '"')
|
|
.replace(/'/g, "'")
|
|
.replace(/</g, '<')
|
|
.replace(/>/g, '>')
|
|
.replace(/ /g, ' ')
|
|
.replace(/&/g, '&')
|
|
.trim()
|
|
}
|
|
|
|
/**
|
|
* `text` without its trailing `char`s. A loop, not `/x+$/`: that regex retries
|
|
* from every character of a long run that is not at the end (quadratic).
|
|
*/
|
|
export function trimEnd(text: string, char: string): string {
|
|
let end = text.length
|
|
while (end > 0 && text[end - 1] === char) end--
|
|
return text.slice(0, end)
|
|
}
|
|
|
|
/** Code-unit order, like a bare `sort()` and, for these ASCII names, Python's `sorted()`; not locale-aware. */
|
|
export function compareCodeUnits(a: string, b: string): number {
|
|
if (a === b) return 0
|
|
return a < b ? -1 : 1
|
|
}
|