mirror of
https://github.com/bookorbit/bookorbit.git
synced 2026-11-03 00:11:37 -06:00
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:
@@ -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) => {
|
||||
|
||||
Reference in New Issue
Block a user