mirror of
https://github.com/thelounge/thelounge.git
synced 2026-08-04 09:02:06 -04:00
## What changed `Network.validate()` now compares a locked network's host against the configured `defaults.host` **case-insensitively**. ## Why In `server/models/network.ts`, `validate()` lowercases the incoming host (hostnames are case-insensitive): ```ts this.host = cleanString(this.host).toLowerCase(); ``` but the `lockNetwork` guard then compared that lowercased value against the **raw** configured default with a strict `!==`: ```ts this.host !== Config.values.defaults.host ``` `Config.values.defaults.host` is never normalized on load, so when an admin's `defaults.host` contains uppercase letters (e.g. `irc.eXample.net`), a persisted network whose stored host had been lowercased (`irc.example.net`) no longer matched the default and was rejected with: > The hostname you specified (irc.example.net) is not allowed. The block is guarded by `this.host.length > 0`, so it doesn't fire on the first connect (locked networks send an empty host there). It only bites **after a restart**, when the persisted network JSON carries the stored host — which is exactly the symptom reported in #4733: the network never reconnects. ## Fix Compare against `Config.values.defaults.host.toLowerCase()`. One line; no behavior change for hosts that already matched. ## Tests Added a regression test to `test/models/network.ts` (`#validate()`), which runs in CI. It sets a mixed-case `defaults.host` under `lockNetwork` + private mode and asserts a network with the same mixed-case host validates successfully. The test fails without the fix (`validate()` returns `false`) and passes with it. - `yarn vitest run test/models/network.ts` — 24/24 pass. - `tsc -p server/tsconfig.json`, eslint and prettier clean on the changed files. Fixes #4733 --------- Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>