fix(reader): accept underscores in KOReader device IDs

Allow KOReader-generated device IDs to pass shared validation so retirement and plugin requests do not fail with HTTP 400.

Fixes #1928
This commit is contained in:
neon
2026-11-02 02:45:38 +00:00
parent cfcd4ca529
commit 305b6087b0
2 changed files with 3 additions and 3 deletions
@@ -1,6 +1,6 @@
import { IsBoolean, IsString, Matches, MaxLength, MinLength } from 'class-validator';
export const KOREADER_DEVICE_ID_REGEX = /^[A-Za-z0-9-]{1,100}$/;
export const KOREADER_DEVICE_ID_REGEX = /^[A-Za-z0-9_-]{1,100}$/;
export class KoreaderDeviceParamDto {
@IsString()
@@ -50,8 +50,8 @@ describe('UpdateKoreaderFilePatternDto', () => {
});
describe('KoreaderDeviceParamDto', () => {
it('accepts a bounded device id', async () => {
await expect(validate(plainToInstance(KoreaderDeviceParamDto, { deviceId: 'device-1' }))).resolves.toHaveLength(0);
it.each(['device-1', 'GanCao_11673992'])('accepts a bounded device id: %s', async (deviceId) => {
await expect(validate(plainToInstance(KoreaderDeviceParamDto, { deviceId }))).resolves.toHaveLength(0);
});
it.each(['', 'device/one', 'device\nlog-entry', 'x'.repeat(101)])('rejects an invalid device id', async (deviceId) => {