diff --git a/snapshot/src/core/config.ts b/snapshot/src/core/config.ts index bf783ab..1a94d60 100644 --- a/snapshot/src/core/config.ts +++ b/snapshot/src/core/config.ts @@ -11,5 +11,8 @@ export function loadConfig(): Config { throw new Error('AUTHOR_PUBKEY_HEX muss 64 hex chars sein') } if (!bootstrapRelay) throw new Error('BOOTSTRAP_RELAY fehlt in env') + if (!bootstrapRelay.startsWith('wss://') && !bootstrapRelay.startsWith('ws://')) { + throw new Error('BOOTSTRAP_RELAY muss eine wss:// (oder ws://) URL sein') + } return { authorPubkeyHex, bootstrapRelay } } diff --git a/snapshot/tests/config.test.ts b/snapshot/tests/config.test.ts index f34d6bc..e1f5fcf 100644 --- a/snapshot/tests/config.test.ts +++ b/snapshot/tests/config.test.ts @@ -20,3 +20,9 @@ Deno.test('loadConfig wirft bei ungueltigem hex', () => { Deno.env.set('BOOTSTRAP_RELAY', 'wss://relay.primal.net') assertThrows(() => loadConfig(), Error, '64 hex') }) + +Deno.test('loadConfig wirft bei ungueltigem BOOTSTRAP_RELAY (kein wss://)', () => { + Deno.env.set('AUTHOR_PUBKEY_HEX', '4fa5d1c413e2b45e10d40bf3562ab701a5331206e359c90baae0e99bfd6c6e41') + Deno.env.set('BOOTSTRAP_RELAY', 'http://relay.example.com') + assertThrows(() => loadConfig(), Error, 'wss://') +})