diff --git a/src/event/cloudevent.ts b/src/event/cloudevent.ts index 4da7075..16c722b 100644 --- a/src/event/cloudevent.ts +++ b/src/event/cloudevent.ts @@ -109,9 +109,9 @@ export class CloudEvent implements CloudEventV1 { // finally process any remaining properties - these are extensions for (const [key, value] of Object.entries(properties)) { - // Extension names should only allow lowercase a-z and 0-9 in the name + // Extension names must only allow lowercase a-z and 0-9 in the name // names should not exceed 20 characters in length - if (!key.match(/^[a-z0-9]{1,20}$/) && strict) { + if (!key.match(/^[a-z0-9]+$/) && strict) { throw new ValidationError(`invalid extension name: ${key} CloudEvents attribute names MUST consist of lower-case letters ('a' to 'z') or digits ('0' to '9') from the ASCII character set. Attribute names SHOULD diff --git a/test/integration/cloud_event_test.ts b/test/integration/cloud_event_test.ts index f45a6f6..8447207 100644 --- a/test/integration/cloud_event_test.ts +++ b/test/integration/cloud_event_test.ts @@ -82,10 +82,10 @@ describe("A CloudEvent", () => { }).throw("invalid extension name"); }); - it("Throw a validation error for invalid extension names, more than 20 chars", () => { + it("Not throw a validation error for invalid extension names, more than 20 chars", () => { expect(() => { new CloudEvent({ "123456789012345678901": "extension1", ...fixture }); - }).throw("invalid extension name"); + }).not.throw("invalid extension name"); }); it("Throws a validation error for invalid uppercase extension names", () => {