From 7f8404a76ddbded5e2b73b35b2af898a56d593ff Mon Sep 17 00:00:00 2001 From: Flo Edelmann Date: Thu, 7 Nov 2024 16:05:38 +0100 Subject: [PATCH] Allow more valid URIs in `assertRabbitMqUri` (#874) * Allow `amqps://` protocol in `assertRabbitMqUri` * Allow trailing slash in `assertRabbitMqUri` * Add more valid URIs to tests --- packages/rabbitmq/src/amqp/utils.ts | 2 +- packages/rabbitmq/src/tests/rabbitmq.utils.spec.ts | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/rabbitmq/src/amqp/utils.ts b/packages/rabbitmq/src/amqp/utils.ts index 366b093c6..b3301095c 100644 --- a/packages/rabbitmq/src/amqp/utils.ts +++ b/packages/rabbitmq/src/amqp/utils.ts @@ -29,7 +29,7 @@ export function matchesRoutingKey( } const rabbitMQRegex = - /^amqp:\/\/(([^:]+):([^@]+)@)?([^:/]+)(:[0-9]+)?(\/[^\/]+)?$/; + /^amqps?:\/\/(([^:]+):([^@]+)@)?([^:/]+)(:[0-9]+)?(\/[^\/]*)?$/; /** * Validates a rabbitmq uri diff --git a/packages/rabbitmq/src/tests/rabbitmq.utils.spec.ts b/packages/rabbitmq/src/tests/rabbitmq.utils.spec.ts index 590b4aa92..4bf17e7de 100644 --- a/packages/rabbitmq/src/tests/rabbitmq.utils.spec.ts +++ b/packages/rabbitmq/src/tests/rabbitmq.utils.spec.ts @@ -69,6 +69,9 @@ describe(matchesRoutingKey.name, () => { assertRabbitMqUri([ 'amqp://rabbitmq:rabbitmq@localhost:4444', 'amqp://rabbitmq:rabbitmq@localhost:1234', + 'amqps://rabbitmq:rabbitmq@localhost:2345', + 'amqp://rabbitmq:rabbitmq@localhost:3456/', + 'amqps://rabbitmq:rabbitmq@localhost:4567/', ]), ).not.toThrowError(); });