From f95e9a66300d420e8bf3581df290649c0a753c9d Mon Sep 17 00:00:00 2001 From: Ruth Di Giacomo Date: Tue, 16 Apr 2024 13:32:25 +0200 Subject: [PATCH 01/19] refactor: email validation --- .../src/attributes/types/strings/AbstractEMailAddress.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/packages/content/src/attributes/types/strings/AbstractEMailAddress.ts b/packages/content/src/attributes/types/strings/AbstractEMailAddress.ts index e374d9870..cb26c5b7e 100644 --- a/packages/content/src/attributes/types/strings/AbstractEMailAddress.ts +++ b/packages/content/src/attributes/types/strings/AbstractEMailAddress.ts @@ -7,8 +7,11 @@ export abstract class AbstractEMailAddress extends AbstractString { @serialize() @validate({ min: 3, - max: 100, - regExp: new RegExp("^[A-Z0-9._%+-]+@[A-Z0-9.-]+.[A-Z]{2,}$", "i") + max: 254, + regExp: new RegExp( + "^[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:[.][a-z0-9!#$%&'*+/=?^_`{|}~-]+){0,}@(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9]){0,1}[.])+[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])$", + "i" + ) }) public override value: string; @@ -16,7 +19,7 @@ export abstract class AbstractEMailAddress extends AbstractString { return super.valueHints.copyWith({ min: 3, max: 100, - pattern: "/^[A-Z0-9._%+-]+@[A-Z0-9.-]+.[A-Z]{2,}$/i" + pattern: "^[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:[.][a-z0-9!#$%&'*+/=?^_`{|}~-]+){0,}@(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9]){0,1}[.])+[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])$/i" }); } From 6ddd188d962457c26b72020feab009044e0ef560 Mon Sep 17 00:00:00 2001 From: Ruth Di Giacomo Date: Mon, 6 May 2024 12:40:01 +0200 Subject: [PATCH 02/19] fix: Email-Validation and add a test for it --- .../types/strings/AbstractEMailAddress.ts | 5 +- .../test/attributes/EmailAddress.test.ts | 59 +++++++++++++++++++ 2 files changed, 62 insertions(+), 2 deletions(-) create mode 100644 packages/content/test/attributes/EmailAddress.test.ts diff --git a/packages/content/src/attributes/types/strings/AbstractEMailAddress.ts b/packages/content/src/attributes/types/strings/AbstractEMailAddress.ts index cb26c5b7e..4492433c4 100644 --- a/packages/content/src/attributes/types/strings/AbstractEMailAddress.ts +++ b/packages/content/src/attributes/types/strings/AbstractEMailAddress.ts @@ -9,7 +9,7 @@ export abstract class AbstractEMailAddress extends AbstractString { min: 3, max: 254, regExp: new RegExp( - "^[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:[.][a-z0-9!#$%&'*+/=?^_`{|}~-]+){0,}@(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9]){0,1}[.])+[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])$", + "^[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:[.][a-z0-9!#$%&'*+/=?^_`{|}~-]+){0,}@(?:[a-z0-9\u00c4\u00e4\u00d6\u00f6\u00dc\u00fc\u00df](?:[a-z\u00c4\u00e4\u00d6\u00f6\u00dc\u00fc\u00df0-9-]{0,61}[a-z\u00c4\u00e4\u00d6\u00f6\u00dc\u00fc\u00df0-9]){0,1}[.])+[a-z\u00c4\u00e4\u00d6\u00f6\u00dc\u00fc\u00df0-9](?:[a-z\u00c4\u00e4\u00d6\u00f6\u00dc\u00fc\u00df0-9-]{0,61}[a-z\u00c4\u00e4\u00d6\u00f6\u00dc\u00fc\u00df0-9])$", "i" ) }) @@ -19,7 +19,8 @@ export abstract class AbstractEMailAddress extends AbstractString { return super.valueHints.copyWith({ min: 3, max: 100, - pattern: "^[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:[.][a-z0-9!#$%&'*+/=?^_`{|}~-]+){0,}@(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9]){0,1}[.])+[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])$/i" + pattern: + "^[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:[.][a-z0-9!#$%&'*+/=?^_`{|}~-]+){0,}@(?:[a-z0-9\u00c4\u00e4\u00d6\u00f6\u00dc\u00fc\u00df](?:[a-z\u00c4\u00e4\u00d6\u00f6\u00dc\u00fc\u00df0-9-]{0,61}[a-z\u00c4\u00e4\u00d6\u00f6\u00dc\u00fc\u00df0-9]){0,1}[.])+[a-z\u00c4\u00e4\u00d6\u00f6\u00dc\u00fc\u00df0-9](?:[a-z\u00c4\u00e4\u00d6\u00f6\u00dc\u00fc\u00df0-9-]{0,61}[a-z\u00c4\u00e4\u00d6\u00f6\u00dc\u00fc\u00df0-9])$/i" }); } diff --git a/packages/content/test/attributes/EmailAddress.test.ts b/packages/content/test/attributes/EmailAddress.test.ts new file mode 100644 index 000000000..10af861a5 --- /dev/null +++ b/packages/content/test/attributes/EmailAddress.test.ts @@ -0,0 +1,59 @@ +import { ParsingError } from "@js-soft/ts-serval"; +import { EMailAddress } from "../../src"; + +describe("creation of RepositoryAttributes of Attribute Value Type EMailAddress", function () { + test("can create a RepositoryAttribute of Attribute Value Type EMailAddress", function () { + const validEMailAdress = EMailAddress.from({ + value: "peter123@inwind.it" + }); + expect(validEMailAdress.value.toString()).toBe("peter123@inwind.it"); + }); + test("can create a RepositoryAttribute of Attribute Value Type EMailAddress with the German 'ä' in its domain", function () { + const validEMailAdress = EMailAddress.from({ + value: "peter123@inwänd.it" + }); + expect(validEMailAdress.value.toString()).toBe("peter123@inwänd.it"); + }); + test("returns an error when trying to create an Attribute Value Type EMailAddress with a blank in the value for EMailAddress", function () { + const invalidEMailAdressCall = () => { + EMailAddress.from({ + value: "Hugo Becker@gmx.de" + }); + }; + expect(invalidEMailAdressCall).toThrow( + new ParsingError( + "EMailAddress", + "value", + "Value does not match regular expression /^[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:[.][a-z0-9!#$%&'*+/=?^_`{|}~-]+){0,}@(?:[a-z0-9ÄäÖöÜüß](?:[a-zÄäÖöÜüß0-9-]{0,61}[a-zÄäÖöÜüß0-9]){0,1}[.])+[a-zÄäÖöÜüß0-9](?:[a-zÄäÖöÜüß0-9-]{0,61}[a-zÄäÖöÜüß0-9])$/i" + ) + ); + }); + test("returns an error when trying to create an Attribute Value Type EMailAddress without the right ending in the value for EMailAddress", function () { + const invalidEMailAdressCall = () => { + EMailAddress.from({ + value: "Becker@gmx" + }); + }; + expect(invalidEMailAdressCall).toThrow( + new ParsingError( + "EMailAddress", + "value", + "Value does not match regular expression /^[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:[.][a-z0-9!#$%&'*+/=?^_`{|}~-]+){0,}@(?:[a-z0-9ÄäÖöÜüß](?:[a-zÄäÖöÜüß0-9-]{0,61}[a-zÄäÖöÜüß0-9]){0,1}[.])+[a-zÄäÖöÜüß0-9](?:[a-zÄäÖöÜüß0-9-]{0,61}[a-zÄäÖöÜüß0-9])$/i" + ) + ); + }); + test("returns an error when trying to create an Attribute Value Type EMailAddress with a - before the . in the value for EMailAddress", function () { + const invalidEMailAdressCall = () => { + EMailAddress.from({ + value: "Becker@gmx-.de" + }); + }; + expect(invalidEMailAdressCall).toThrow( + new ParsingError( + "EMailAddress", + "value", + "Value does not match regular expression /^[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:[.][a-z0-9!#$%&'*+/=?^_`{|}~-]+){0,}@(?:[a-z0-9ÄäÖöÜüß](?:[a-zÄäÖöÜüß0-9-]{0,61}[a-zÄäÖöÜüß0-9]){0,1}[.])+[a-zÄäÖöÜüß0-9](?:[a-zÄäÖöÜüß0-9-]{0,61}[a-zÄäÖöÜüß0-9])$/i" + ) + ); + }); +}); From 64df3f41d053c85d8c95b7a10df7dd98243738dc Mon Sep 17 00:00:00 2001 From: Ruth Di Giacomo Date: Mon, 6 May 2024 12:40:28 +0200 Subject: [PATCH 03/19] fix: Website Validation and add a test for it --- .../attributes/types/strings/AbstractURL.ts | 4 +- .../content/test/attributes/Website.test.ts | 73 +++++++++++++++++++ 2 files changed, 75 insertions(+), 2 deletions(-) create mode 100644 packages/content/test/attributes/Website.test.ts diff --git a/packages/content/src/attributes/types/strings/AbstractURL.ts b/packages/content/src/attributes/types/strings/AbstractURL.ts index 65dbaf13f..25c6e18d1 100644 --- a/packages/content/src/attributes/types/strings/AbstractURL.ts +++ b/packages/content/src/attributes/types/strings/AbstractURL.ts @@ -9,7 +9,7 @@ export abstract class AbstractURL extends AbstractString { max: 1024, regExp: new RegExp( // eslint-disable-next-line no-useless-escape - /((([A-Za-z]{3,9}:(?:\/\/)?)(?:[-;:&=\+\$,\w]+@)?[A-Za-z0-9.-]+|(?:www.|[-;:&=\+\$,\w]+@)[A-Za-z0-9.-]+)((?:\/[\+~%\/.\w-_]*)?\??(?:[-\+=&;%@.\w_]*)#?(?:[\w]*))?)/ + /^(?:|[A-Za-z]{3,9}:(?:\/\/)?|[:](?:\/\/)?|(?:\/\/))(?:(www[.])(?:[a-z0-9\u00c4\u00e4\u00d6\u00f6\u00dc\u00fc\u00df](?:[A-Za-z\u00c4\u00e4\u00d6\u00f6\u00dc\u00fc\u00df0-9-]{0,61}[A-Za-z\u00c4\u00e4\u00d6\u00f6\u00dc\u00fc\u00df0-9]){0,1}[.])|((?!www.)(?:[a-z0-9\u00c4\u00e4\u00d6\u00f6\u00dc\u00fc\u00df](?:[A-Za-z\u00c4\u00e4\u00d6\u00f6\u00dc\u00fc\u00df0-9-]{0,61}[A-Za-z\u00c4\u00e4\u00d6\u00f6\u00dc\u00fc\u00df0-9]){0,1}[.])))[A-Za-z\u00c4\u00e4\u00d6\u00f6\u00dc\u00fc\u00df0-9](?:[A-Za-z\u00c4\u00e4\u00d6\u00f6\u00dc\u00fc\u00df0-9-]{0,61}[A-Za-z\u00c4\u00e4\u00d6\u00f6\u00dc\u00fc\u00df0-9])(\:[0-9]+){0,}(?:[/][\w\u00c4\u00e4\u00d6\u00f6\u00dc\u00fc\u00df\-\._~:/?#[\]@!\$&'\(\)\*\+,;=.]{0,}){0,}$/ ) }) public override value: string; @@ -19,7 +19,7 @@ export abstract class AbstractURL extends AbstractString { min: 3, max: 1024, pattern: - "/((([A-Za-z]{3,9}:(?:\\/\\/)?)(?:[-;:&=\\+\\$,\\w]+@)?[A-Za-z0-9.-]+|(?:www.|[-;:&=\\+\\$,\\w]+@)[A-Za-z0-9.-]+)((?:\\/[\\+~%\\/.\\w\\-_]*)?\\??(?:[-\\+=&;%@.\\w_]*)#?(?:[\\w]*))?)/" + "/^(?:|[A-Za-z]{3,9}:(?://)?|[:](?://)?|(?://))(?:(www[.])(?:[a-z0-9\u00c4\u00e4\u00d6\u00f6\u00dc\u00fc\u00df](?:[A-Za-z\u00c4\u00e4\u00d6\u00f6\u00dc\u00fc\u00df0-9-]{0,61}[A-Za-z\u00c4\u00e4\u00d6\u00f6\u00dc\u00fc\u00df0-9]){0,1}[.])|((?!www.)(?:[a-z0-9\u00c4\u00e4\u00d6\u00f6\u00dc\u00fc\u00df](?:[A-Za-z\u00c4\u00e4\u00d6\u00f6\u00dc\u00fc\u00df0-9-]{0,61}[A-Za-z\u00c4\u00e4\u00d6\u00f6\u00dc\u00fc\u00df0-9]){0,1}[.])))[A-Za-z\u00c4\u00e4\u00d6\u00f6\u00dc\u00fc\u00df0-9](?:[A-Za-z\u00c4\u00e4\u00d6\u00f6\u00dc\u00fc\u00df0-9-]{0,61}[A-Za-z\u00c4\u00e4\u00d6\u00f6\u00dc\u00fc\u00df0-9])(:[0-9]+){0,}(?:[/][w\u00c4\u00e4\u00d6\u00f6\u00dc\u00fc\u00df-._~:/?#[]@!$&'()*+,;=.]{0,}){0,}$/" }); } diff --git a/packages/content/test/attributes/Website.test.ts b/packages/content/test/attributes/Website.test.ts new file mode 100644 index 000000000..0573f8de7 --- /dev/null +++ b/packages/content/test/attributes/Website.test.ts @@ -0,0 +1,73 @@ +import { ParsingError } from "@js-soft/ts-serval"; +import { Website } from "../../src"; + +describe("creation of RepositoryAttributes of Attribute Value Type Website", function () { + test("can create a RepositoryAttribute of Attribute Value Type Website", function () { + const validWebsite = Website.from({ + value: "https://inwind.it" + }); + expect(validWebsite.value.toString()).toBe("https://inwind.it"); + }); + test("can create a RepositoryAttribute of Attribute Value Type Website with the German 'ä' in its domain", function () { + const validWebsite = Website.from({ + value: "https://inwänd.it" + }); + expect(validWebsite.value.toString()).toBe("https://inwänd.it"); + }); + test("can create a RepositoryAttribute of Attribute Value Type Website without www.", function () { + const validWebsite = Website.from({ + value: "//google.it" + }); + expect(validWebsite.value.toString()).toBe("//google.it"); + }); + test("can create a RepositoryAttribute of Attribute Value Type Website with a enhanced path", function () { + const validWebsite = Website.from({ + value: "https://enmeshed.de/blog/meilenstein-enmeshed-als-komponente-ablage-in-mein-bildungsraum-geht-in-die-testphase-der-beta-version/" + }); + expect(validWebsite.value.toString()).toBe( + "https://enmeshed.de/blog/meilenstein-enmeshed-als-komponente-ablage-in-mein-bildungsraum-geht-in-die-testphase-der-beta-version/" + ); + }); + test("returns an error when trying to create an Attribute Value Type Website with a blank in the value for Website", function () { + const invalidWebsiteCall = () => { + Website.from({ + value: "Hugo https://inwind.it" + }); + }; + expect(invalidWebsiteCall).toThrow( + new ParsingError( + "Website", + "value", + "Value does not match regular expression /^(?:|[A-Za-z]{3,9}:(?:\\/\\/)?|[:](?:\\/\\/)?|(?:\\/\\/))(?:(www[.])(?:[a-z0-9\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df](?:[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9-]{0,61}[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9]){0,1}[.])|((?!www.)(?:[a-z0-9\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df](?:[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9-]{0,61}[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9]){0,1}[.])))[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9](?:[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9-]{0,61}[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9])(\\:[0-9]+){0,}(?:[/][\\w\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df\\-\\._~:/?#[\\]@!\\$&'\\(\\)\\*\\+,;=.]{0,}){0,}$/" + ) + ); + }); + test("returns an error when trying to create an Attribute Value Type Website without the right ending when it starts with www.", function () { + const invalidWebsiteCall = () => { + Website.from({ + value: "www.google" + }); + }; + expect(invalidWebsiteCall).toThrow( + new ParsingError( + "Website", + "value", + "Value does not match regular expression /^(?:|[A-Za-z]{3,9}:(?:\\/\\/)?|[:](?:\\/\\/)?|(?:\\/\\/))(?:(www[.])(?:[a-z0-9\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df](?:[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9-]{0,61}[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9]){0,1}[.])|((?!www.)(?:[a-z0-9\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df](?:[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9-]{0,61}[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9]){0,1}[.])))[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9](?:[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9-]{0,61}[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9])(\\:[0-9]+){0,}(?:[/][\\w\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df\\-\\._~:/?#[\\]@!\\$&'\\(\\)\\*\\+,;=.]{0,}){0,}$/" + ) + ); + }); + test("returns an error when trying to create an Attribute Value Type Website with a - before the . in the value for Website", function () { + const invalidWebsiteCall = () => { + Website.from({ + value: "google-.de" + }); + }; + expect(invalidWebsiteCall).toThrow( + new ParsingError( + "Website", + "value", + "Value does not match regular expression /^(?:|[A-Za-z]{3,9}:(?:\\/\\/)?|[:](?:\\/\\/)?|(?:\\/\\/))(?:(www[.])(?:[a-z0-9\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df](?:[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9-]{0,61}[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9]){0,1}[.])|((?!www.)(?:[a-z0-9\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df](?:[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9-]{0,61}[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9]){0,1}[.])))[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9](?:[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9-]{0,61}[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9])(\\:[0-9]+){0,}(?:[/][\\w\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df\\-\\._~:/?#[\\]@!\\$&'\\(\\)\\*\\+,;=.]{0,}){0,}$/" + ) + ); + }); +}); From aa49e8aa908d006216c37f4a42c753ea4b2e1fd2 Mon Sep 17 00:00:00 2001 From: Ruth Di Giacomo Date: Tue, 7 May 2024 11:19:07 +0200 Subject: [PATCH 04/19] feat: change regexp from Url --- .../content/src/attributes/types/strings/AbstractURL.ts | 4 ++-- packages/content/test/attributes/Website.test.ts | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/content/src/attributes/types/strings/AbstractURL.ts b/packages/content/src/attributes/types/strings/AbstractURL.ts index 25c6e18d1..7ea45cd81 100644 --- a/packages/content/src/attributes/types/strings/AbstractURL.ts +++ b/packages/content/src/attributes/types/strings/AbstractURL.ts @@ -9,7 +9,7 @@ export abstract class AbstractURL extends AbstractString { max: 1024, regExp: new RegExp( // eslint-disable-next-line no-useless-escape - /^(?:|[A-Za-z]{3,9}:(?:\/\/)?|[:](?:\/\/)?|(?:\/\/))(?:(www[.])(?:[a-z0-9\u00c4\u00e4\u00d6\u00f6\u00dc\u00fc\u00df](?:[A-Za-z\u00c4\u00e4\u00d6\u00f6\u00dc\u00fc\u00df0-9-]{0,61}[A-Za-z\u00c4\u00e4\u00d6\u00f6\u00dc\u00fc\u00df0-9]){0,1}[.])|((?!www.)(?:[a-z0-9\u00c4\u00e4\u00d6\u00f6\u00dc\u00fc\u00df](?:[A-Za-z\u00c4\u00e4\u00d6\u00f6\u00dc\u00fc\u00df0-9-]{0,61}[A-Za-z\u00c4\u00e4\u00d6\u00f6\u00dc\u00fc\u00df0-9]){0,1}[.])))[A-Za-z\u00c4\u00e4\u00d6\u00f6\u00dc\u00fc\u00df0-9](?:[A-Za-z\u00c4\u00e4\u00d6\u00f6\u00dc\u00fc\u00df0-9-]{0,61}[A-Za-z\u00c4\u00e4\u00d6\u00f6\u00dc\u00fc\u00df0-9])(\:[0-9]+){0,}(?:[/][\w\u00c4\u00e4\u00d6\u00f6\u00dc\u00fc\u00df\-\._~:/?#[\]@!\$&'\(\)\*\+,;=.]{0,}){0,}$/ + /^(?:|[A-Za-z]{3,9}:(?:\/\/)?|[:](?:\/\/)?|(?:\/\/))(?:(www[.])(?:[a-z0-9\u00c4\u00e4\u00d6\u00f6\u00dc\u00fc\u00df](?:[A-Za-z\u00c4\u00e4\u00d6\u00f6\u00dc\u00fc\u00df0-9-]{0,61}[A-Za-z\u00c4\u00e4\u00d6\u00f6\u00dc\u00fc\u00df0-9]){0,1}[.])|((?!www.)(?:[a-z0-9\u00c4\u00e4\u00d6\u00f6\u00dc\u00fc\u00df](?:[A-Za-z\u00c4\u00e4\u00d6\u00f6\u00dc\u00fc\u00df0-9-]{0,61}[A-Za-z\u00c4\u00e4\u00d6\u00f6\u00dc\u00fc\u00df0-9]){0,1}[.])))[A-Za-z\u00c4\u00e4\u00d6\u00f6\u00dc\u00fc\u00df0-9](?:[A-Za-z\u00c4\u00e4\u00d6\u00f6\u00dc\u00fc\u00df0-9-]{0,61}[A-Za-z\u00c4\u00e4\u00d6\u00f6\u00dc\u00fc\u00df0-9])(\:[0-9]+){0,}(?:[/][\w\u00c4\u00e4\u00d6\u00f6\u00dc\u00fc\u00df\-_?#@!\$&'\(\)\*\+,;=]{0,}){0,}$/ ) }) public override value: string; @@ -19,7 +19,7 @@ export abstract class AbstractURL extends AbstractString { min: 3, max: 1024, pattern: - "/^(?:|[A-Za-z]{3,9}:(?://)?|[:](?://)?|(?://))(?:(www[.])(?:[a-z0-9\u00c4\u00e4\u00d6\u00f6\u00dc\u00fc\u00df](?:[A-Za-z\u00c4\u00e4\u00d6\u00f6\u00dc\u00fc\u00df0-9-]{0,61}[A-Za-z\u00c4\u00e4\u00d6\u00f6\u00dc\u00fc\u00df0-9]){0,1}[.])|((?!www.)(?:[a-z0-9\u00c4\u00e4\u00d6\u00f6\u00dc\u00fc\u00df](?:[A-Za-z\u00c4\u00e4\u00d6\u00f6\u00dc\u00fc\u00df0-9-]{0,61}[A-Za-z\u00c4\u00e4\u00d6\u00f6\u00dc\u00fc\u00df0-9]){0,1}[.])))[A-Za-z\u00c4\u00e4\u00d6\u00f6\u00dc\u00fc\u00df0-9](?:[A-Za-z\u00c4\u00e4\u00d6\u00f6\u00dc\u00fc\u00df0-9-]{0,61}[A-Za-z\u00c4\u00e4\u00d6\u00f6\u00dc\u00fc\u00df0-9])(:[0-9]+){0,}(?:[/][w\u00c4\u00e4\u00d6\u00f6\u00dc\u00fc\u00df-._~:/?#[]@!$&'()*+,;=.]{0,}){0,}$/" + "/^(?:|[A-Za-z]{3,9}:(?://)?|[:](?://)?|(?://))(?:(www[.])(?:[a-z0-9\u00c4\u00e4\u00d6\u00f6\u00dc\u00fc\u00df](?:[A-Za-z\u00c4\u00e4\u00d6\u00f6\u00dc\u00fc\u00df0-9-]{0,61}[A-Za-z\u00c4\u00e4\u00d6\u00f6\u00dc\u00fc\u00df0-9]){0,1}[.])|((?!www.)(?:[a-z0-9\u00c4\u00e4\u00d6\u00f6\u00dc\u00fc\u00df](?:[A-Za-z\u00c4\u00e4\u00d6\u00f6\u00dc\u00fc\u00df0-9-]{0,61}[A-Za-z\u00c4\u00e4\u00d6\u00f6\u00dc\u00fc\u00df0-9]){0,1}[.])))[A-Za-z\u00c4\u00e4\u00d6\u00f6\u00dc\u00fc\u00df0-9](?:[A-Za-z\u00c4\u00e4\u00d6\u00f6\u00dc\u00fc\u00df0-9-]{0,61}[A-Za-z\u00c4\u00e4\u00d6\u00f6\u00dc\u00fc\u00df0-9])(:[0-9]+){0,}(?:[/][w\u00c4\u00e4\u00d6\u00f6\u00dc\u00fc\u00df-_?#@!$&'()*+,;=]{0,}){0,}$/" }); } diff --git a/packages/content/test/attributes/Website.test.ts b/packages/content/test/attributes/Website.test.ts index 0573f8de7..bf3bdf750 100644 --- a/packages/content/test/attributes/Website.test.ts +++ b/packages/content/test/attributes/Website.test.ts @@ -38,7 +38,7 @@ describe("creation of RepositoryAttributes of Attribute Value Type Website", fun new ParsingError( "Website", "value", - "Value does not match regular expression /^(?:|[A-Za-z]{3,9}:(?:\\/\\/)?|[:](?:\\/\\/)?|(?:\\/\\/))(?:(www[.])(?:[a-z0-9\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df](?:[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9-]{0,61}[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9]){0,1}[.])|((?!www.)(?:[a-z0-9\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df](?:[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9-]{0,61}[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9]){0,1}[.])))[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9](?:[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9-]{0,61}[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9])(\\:[0-9]+){0,}(?:[/][\\w\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df\\-\\._~:/?#[\\]@!\\$&'\\(\\)\\*\\+,;=.]{0,}){0,}$/" + "Value does not match regular expression /^(?:|[A-Za-z]{3,9}:(?:\\/\\/)?|[:](?:\\/\\/)?|(?:\\/\\/))(?:(www[.])(?:[a-z0-9\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df](?:[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9-]{0,61}[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9]){0,1}[.])|((?!www.)(?:[a-z0-9\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df](?:[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9-]{0,61}[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9]){0,1}[.])))[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9](?:[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9-]{0,61}[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9])(\\:[0-9]+){0,}(?:[/][\\w\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df\\-_?#@!\\$&'\\(\\)\\*\\+,;=]{0,}){0,}$/" ) ); }); @@ -52,7 +52,7 @@ describe("creation of RepositoryAttributes of Attribute Value Type Website", fun new ParsingError( "Website", "value", - "Value does not match regular expression /^(?:|[A-Za-z]{3,9}:(?:\\/\\/)?|[:](?:\\/\\/)?|(?:\\/\\/))(?:(www[.])(?:[a-z0-9\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df](?:[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9-]{0,61}[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9]){0,1}[.])|((?!www.)(?:[a-z0-9\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df](?:[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9-]{0,61}[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9]){0,1}[.])))[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9](?:[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9-]{0,61}[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9])(\\:[0-9]+){0,}(?:[/][\\w\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df\\-\\._~:/?#[\\]@!\\$&'\\(\\)\\*\\+,;=.]{0,}){0,}$/" + "Value does not match regular expression /^(?:|[A-Za-z]{3,9}:(?:\\/\\/)?|[:](?:\\/\\/)?|(?:\\/\\/))(?:(www[.])(?:[a-z0-9\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df](?:[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9-]{0,61}[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9]){0,1}[.])|((?!www.)(?:[a-z0-9\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df](?:[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9-]{0,61}[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9]){0,1}[.])))[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9](?:[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9-]{0,61}[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9])(\\:[0-9]+){0,}(?:[/][\\w\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df\\-_?#@!\\$&'\\(\\)\\*\\+,;=]{0,}){0,}$/" ) ); }); @@ -66,7 +66,7 @@ describe("creation of RepositoryAttributes of Attribute Value Type Website", fun new ParsingError( "Website", "value", - "Value does not match regular expression /^(?:|[A-Za-z]{3,9}:(?:\\/\\/)?|[:](?:\\/\\/)?|(?:\\/\\/))(?:(www[.])(?:[a-z0-9\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df](?:[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9-]{0,61}[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9]){0,1}[.])|((?!www.)(?:[a-z0-9\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df](?:[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9-]{0,61}[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9]){0,1}[.])))[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9](?:[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9-]{0,61}[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9])(\\:[0-9]+){0,}(?:[/][\\w\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df\\-\\._~:/?#[\\]@!\\$&'\\(\\)\\*\\+,;=.]{0,}){0,}$/" + "Value does not match regular expression /^(?:|[A-Za-z]{3,9}:(?:\\/\\/)?|[:](?:\\/\\/)?|(?:\\/\\/))(?:(www[.])(?:[a-z0-9\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df](?:[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9-]{0,61}[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9]){0,1}[.])|((?!www.)(?:[a-z0-9\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df](?:[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9-]{0,61}[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9]){0,1}[.])))[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9](?:[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9-]{0,61}[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9])(\\:[0-9]+){0,}(?:[/][\\w\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df\\-_?#@!\\$&'\\(\\)\\*\\+,;=]{0,}){0,}$/" ) ); }); From ea00966d3944aa8169d21ce401a06894787b73c2 Mon Sep 17 00:00:00 2001 From: Ruth Di Giacomo Date: Tue, 7 May 2024 11:43:55 +0200 Subject: [PATCH 05/19] chore: version bump --- packages/content/package.json | 2 +- packages/runtime/package.json | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/content/package.json b/packages/content/package.json index 0d54533f1..7e662b315 100644 --- a/packages/content/package.json +++ b/packages/content/package.json @@ -1,6 +1,6 @@ { "name": "@nmshd/content", - "version": "2.9.0", + "version": "2.9.1", "description": "The content library defines data structures that can be transmitted using the transport library.", "homepage": "https://enmeshed.eu", "repository": { diff --git a/packages/runtime/package.json b/packages/runtime/package.json index 8c68483e5..05964209a 100644 --- a/packages/runtime/package.json +++ b/packages/runtime/package.json @@ -1,6 +1,6 @@ { "name": "@nmshd/runtime", - "version": "4.6.0", + "version": "4.6.1", "description": "The enmeshed client runtime.", "homepage": "https://enmeshed.eu", "repository": { @@ -57,7 +57,7 @@ "@js-soft/ts-serval": "2.0.10", "@js-soft/ts-utils": "^2.3.3", "@nmshd/consumption": "3.10.0", - "@nmshd/content": "2.9.0", + "@nmshd/content": "2.9.1", "@nmshd/crypto": "2.0.6", "@nmshd/transport": "2.5.0", "ajv": "^8.13.0", From 8b35b327e53c35cc1cbe6b599a967bbe5d08d953 Mon Sep 17 00:00:00 2001 From: Ruth Di Giacomo Date: Wed, 8 May 2024 10:06:44 +0200 Subject: [PATCH 06/19] refactor: test for website --- packages/content/test/attributes/Website.test.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/packages/content/test/attributes/Website.test.ts b/packages/content/test/attributes/Website.test.ts index bf3bdf750..a2240053a 100644 --- a/packages/content/test/attributes/Website.test.ts +++ b/packages/content/test/attributes/Website.test.ts @@ -2,6 +2,12 @@ import { ParsingError } from "@js-soft/ts-serval"; import { Website } from "../../src"; describe("creation of RepositoryAttributes of Attribute Value Type Website", function () { + test("can create a RepositoryAttribute of Attribute Value Type Website with the beginning www.", function () { + const validWebsite = Website.from({ + value: "www.inwind.it" + }); + expect(validWebsite.value.toString()).toBe("www.inwind.it"); + }); test("can create a RepositoryAttribute of Attribute Value Type Website", function () { const validWebsite = Website.from({ value: "https://inwind.it" @@ -28,7 +34,7 @@ describe("creation of RepositoryAttributes of Attribute Value Type Website", fun "https://enmeshed.de/blog/meilenstein-enmeshed-als-komponente-ablage-in-mein-bildungsraum-geht-in-die-testphase-der-beta-version/" ); }); - test("returns an error when trying to create an Attribute Value Type Website with a blank in the value for Website", function () { + test("returns an error when trying to create an Attribute Value Type Website wich contains more than only the address of the website", function () { const invalidWebsiteCall = () => { Website.from({ value: "Hugo https://inwind.it" From ee5b37b629b72df5847576f7cc46b38347785f1d Mon Sep 17 00:00:00 2001 From: Ruth Di Giacomo Date: Mon, 13 May 2024 10:51:11 +0200 Subject: [PATCH 07/19] refactor: changed wording of the test --- packages/content/test/attributes/Website.test.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/content/test/attributes/Website.test.ts b/packages/content/test/attributes/Website.test.ts index a2240053a..64305238e 100644 --- a/packages/content/test/attributes/Website.test.ts +++ b/packages/content/test/attributes/Website.test.ts @@ -26,7 +26,7 @@ describe("creation of RepositoryAttributes of Attribute Value Type Website", fun }); expect(validWebsite.value.toString()).toBe("//google.it"); }); - test("can create a RepositoryAttribute of Attribute Value Type Website with a enhanced path", function () { + test("can create a RepositoryAttribute of Attribute Value Type Website with an enhanced path", function () { const validWebsite = Website.from({ value: "https://enmeshed.de/blog/meilenstein-enmeshed-als-komponente-ablage-in-mein-bildungsraum-geht-in-die-testphase-der-beta-version/" }); @@ -34,10 +34,10 @@ describe("creation of RepositoryAttributes of Attribute Value Type Website", fun "https://enmeshed.de/blog/meilenstein-enmeshed-als-komponente-ablage-in-mein-bildungsraum-geht-in-die-testphase-der-beta-version/" ); }); - test("returns an error when trying to create an Attribute Value Type Website wich contains more than only the address of the website", function () { + test("returns an error when trying to create an Attribute Value Type EMailAddress with a blank in the value for EMailAddress", function () { const invalidWebsiteCall = () => { Website.from({ - value: "Hugo https://inwind.it" + value: "https://inwind.test it" }); }; expect(invalidWebsiteCall).toThrow( From 7bf9bfdc246a656d55d167af4631e5f43c83ebff Mon Sep 17 00:00:00 2001 From: Ruth Di Giacomo Date: Tue, 14 May 2024 09:40:00 +0200 Subject: [PATCH 08/19] refactor: Tests for Email and Website --- .../types/strings/AbstractEMailAddress.ts | 2 +- .../test/attributes/EmailAddress.test.ts | 46 ++++++++++++------- .../content/test/attributes/Website.test.ts | 32 +++++++++---- 3 files changed, 54 insertions(+), 26 deletions(-) diff --git a/packages/content/src/attributes/types/strings/AbstractEMailAddress.ts b/packages/content/src/attributes/types/strings/AbstractEMailAddress.ts index 4492433c4..5c584796f 100644 --- a/packages/content/src/attributes/types/strings/AbstractEMailAddress.ts +++ b/packages/content/src/attributes/types/strings/AbstractEMailAddress.ts @@ -18,7 +18,7 @@ export abstract class AbstractEMailAddress extends AbstractString { public static override get valueHints(): ValueHints { return super.valueHints.copyWith({ min: 3, - max: 100, + max: 254, pattern: "^[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:[.][a-z0-9!#$%&'*+/=?^_`{|}~-]+){0,}@(?:[a-z0-9\u00c4\u00e4\u00d6\u00f6\u00dc\u00fc\u00df](?:[a-z\u00c4\u00e4\u00d6\u00f6\u00dc\u00fc\u00df0-9-]{0,61}[a-z\u00c4\u00e4\u00d6\u00f6\u00dc\u00fc\u00df0-9]){0,1}[.])+[a-z\u00c4\u00e4\u00d6\u00f6\u00dc\u00fc\u00df0-9](?:[a-z\u00c4\u00e4\u00d6\u00f6\u00dc\u00fc\u00df0-9-]{0,61}[a-z\u00c4\u00e4\u00d6\u00f6\u00dc\u00fc\u00df0-9])$/i" }); diff --git a/packages/content/test/attributes/EmailAddress.test.ts b/packages/content/test/attributes/EmailAddress.test.ts index 10af861a5..d7ece286f 100644 --- a/packages/content/test/attributes/EmailAddress.test.ts +++ b/packages/content/test/attributes/EmailAddress.test.ts @@ -1,26 +1,26 @@ import { ParsingError } from "@js-soft/ts-serval"; import { EMailAddress } from "../../src"; -describe("creation of RepositoryAttributes of Attribute Value Type EMailAddress", function () { - test("can create a RepositoryAttribute of Attribute Value Type EMailAddress", function () { - const validEMailAdress = EMailAddress.from({ +describe("creation of RepositoryAttributes of Attribute value type EMailAddress", function () { + test("can create a RepositoryAttribute of Attribute value type EMailAddress", function () { + const validEMailAddress = EMailAddress.from({ value: "peter123@inwind.it" }); - expect(validEMailAdress.value.toString()).toBe("peter123@inwind.it"); + expect(validEMailAddress.value.toString()).toBe("peter123@inwind.it"); }); - test("can create a RepositoryAttribute of Attribute Value Type EMailAddress with the German 'ä' in its domain", function () { - const validEMailAdress = EMailAddress.from({ + test("can create a RepositoryAttribute of Attribute value type EMailAddress with the German 'ä' in its domain", function () { + const validEMailAddress = EMailAddress.from({ value: "peter123@inwänd.it" }); - expect(validEMailAdress.value.toString()).toBe("peter123@inwänd.it"); + expect(validEMailAddress.value.toString()).toBe("peter123@inwänd.it"); }); - test("returns an error when trying to create an Attribute Value Type EMailAddress with a blank in the value for EMailAddress", function () { - const invalidEMailAdressCall = () => { + test("returns an error when trying to create an Attribute value type EMailAddress with a blank in the value for EMailAddress", function () { + const invalidEMailAddressCall = () => { EMailAddress.from({ value: "Hugo Becker@gmx.de" }); }; - expect(invalidEMailAdressCall).toThrow( + expect(invalidEMailAddressCall).toThrow( new ParsingError( "EMailAddress", "value", @@ -28,13 +28,13 @@ describe("creation of RepositoryAttributes of Attribute Value Type EMailAddress" ) ); }); - test("returns an error when trying to create an Attribute Value Type EMailAddress without the right ending in the value for EMailAddress", function () { - const invalidEMailAdressCall = () => { + test("returns an error when trying to create an Attribute value type EMailAddress without the right ending in the value for EMailAddress", function () { + const invalidEMailAddressCall = () => { EMailAddress.from({ value: "Becker@gmx" }); }; - expect(invalidEMailAdressCall).toThrow( + expect(invalidEMailAddressCall).toThrow( new ParsingError( "EMailAddress", "value", @@ -42,13 +42,27 @@ describe("creation of RepositoryAttributes of Attribute Value Type EMailAddress" ) ); }); - test("returns an error when trying to create an Attribute Value Type EMailAddress with a - before the . in the value for EMailAddress", function () { - const invalidEMailAdressCall = () => { + test("returns an error when trying to create an Attribute value type EMailAddress with a domain which ends with a - because this is not allowed for domains.", function () { + const invalidEMailAddressCall = () => { EMailAddress.from({ value: "Becker@gmx-.de" }); }; - expect(invalidEMailAdressCall).toThrow( + expect(invalidEMailAddressCall).toThrow( + new ParsingError( + "EMailAddress", + "value", + "Value does not match regular expression /^[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:[.][a-z0-9!#$%&'*+/=?^_`{|}~-]+){0,}@(?:[a-z0-9ÄäÖöÜüß](?:[a-zÄäÖöÜüß0-9-]{0,61}[a-zÄäÖöÜüß0-9]){0,1}[.])+[a-zÄäÖöÜüß0-9](?:[a-zÄäÖöÜüß0-9-]{0,61}[a-zÄäÖöÜüß0-9])$/i" + ) + ); + }); + test("returns an error when trying to create an Attribute value type EMailAddress with a domain which begins with a - because this is not allowed for domains.", function () { + const invalidEMailAddressCall = () => { + EMailAddress.from({ + value: "Becker@-gmx.de" + }); + }; + expect(invalidEMailAddressCall).toThrow( new ParsingError( "EMailAddress", "value", diff --git a/packages/content/test/attributes/Website.test.ts b/packages/content/test/attributes/Website.test.ts index 64305238e..e02ff47c2 100644 --- a/packages/content/test/attributes/Website.test.ts +++ b/packages/content/test/attributes/Website.test.ts @@ -1,32 +1,32 @@ import { ParsingError } from "@js-soft/ts-serval"; import { Website } from "../../src"; -describe("creation of RepositoryAttributes of Attribute Value Type Website", function () { - test("can create a RepositoryAttribute of Attribute Value Type Website with the beginning www.", function () { +describe("creation of RepositoryAttributes of Attribute value type Website", function () { + test("can create a RepositoryAttribute of Attribute value type Website with the beginning www.", function () { const validWebsite = Website.from({ value: "www.inwind.it" }); expect(validWebsite.value.toString()).toBe("www.inwind.it"); }); - test("can create a RepositoryAttribute of Attribute Value Type Website", function () { + test("can create a RepositoryAttribute of Attribute value type Website", function () { const validWebsite = Website.from({ value: "https://inwind.it" }); expect(validWebsite.value.toString()).toBe("https://inwind.it"); }); - test("can create a RepositoryAttribute of Attribute Value Type Website with the German 'ä' in its domain", function () { + test("can create a RepositoryAttribute of Attribute value type Website with the German 'ä' in its domain", function () { const validWebsite = Website.from({ value: "https://inwänd.it" }); expect(validWebsite.value.toString()).toBe("https://inwänd.it"); }); - test("can create a RepositoryAttribute of Attribute Value Type Website without www.", function () { + test("can create a RepositoryAttribute of Attribute value type Website without www.", function () { const validWebsite = Website.from({ value: "//google.it" }); expect(validWebsite.value.toString()).toBe("//google.it"); }); - test("can create a RepositoryAttribute of Attribute Value Type Website with an enhanced path", function () { + test("can create a RepositoryAttribute of Attribute value type Website with an enhanced path", function () { const validWebsite = Website.from({ value: "https://enmeshed.de/blog/meilenstein-enmeshed-als-komponente-ablage-in-mein-bildungsraum-geht-in-die-testphase-der-beta-version/" }); @@ -34,7 +34,7 @@ describe("creation of RepositoryAttributes of Attribute Value Type Website", fun "https://enmeshed.de/blog/meilenstein-enmeshed-als-komponente-ablage-in-mein-bildungsraum-geht-in-die-testphase-der-beta-version/" ); }); - test("returns an error when trying to create an Attribute Value Type EMailAddress with a blank in the value for EMailAddress", function () { + test("returns an error when trying to create an Attribute value type Website with a blank in the value for Website", function () { const invalidWebsiteCall = () => { Website.from({ value: "https://inwind.test it" @@ -48,7 +48,7 @@ describe("creation of RepositoryAttributes of Attribute Value Type Website", fun ) ); }); - test("returns an error when trying to create an Attribute Value Type Website without the right ending when it starts with www.", function () { + test("returns an error when trying to create an Attribute value type Website without the right ending when it starts with www.", function () { const invalidWebsiteCall = () => { Website.from({ value: "www.google" @@ -62,7 +62,7 @@ describe("creation of RepositoryAttributes of Attribute Value Type Website", fun ) ); }); - test("returns an error when trying to create an Attribute Value Type Website with a - before the . in the value for Website", function () { + test("returns an error when trying to create an Attribute value type Website with a domain which ends with a - because this is not allowed for domains.", function () { const invalidWebsiteCall = () => { Website.from({ value: "google-.de" @@ -76,4 +76,18 @@ describe("creation of RepositoryAttributes of Attribute Value Type Website", fun ) ); }); + test("returns an error when trying to create an Attribute value type Website with a domain which begins with a - because this is not allowed for domains.", function () { + const invalidWebsiteCall = () => { + Website.from({ + value: "-google.de" + }); + }; + expect(invalidWebsiteCall).toThrow( + new ParsingError( + "Website", + "value", + "Value does not match regular expression /^(?:|[A-Za-z]{3,9}:(?:\\/\\/)?|[:](?:\\/\\/)?|(?:\\/\\/))(?:(www[.])(?:[a-z0-9\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df](?:[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9-]{0,61}[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9]){0,1}[.])|((?!www.)(?:[a-z0-9\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df](?:[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9-]{0,61}[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9]){0,1}[.])))[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9](?:[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9-]{0,61}[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9])(\\:[0-9]+){0,}(?:[/][\\w\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df\\-_?#@!\\$&'\\(\\)\\*\\+,;=]{0,}){0,}$/" + ) + ); + }); }); From 76e95e113fc998ea2a2888e7e6c9aa01ec1b2fbc Mon Sep 17 00:00:00 2001 From: Ruth Di Giacomo Date: Tue, 14 May 2024 10:43:32 +0200 Subject: [PATCH 09/19] refactor: change string in regexp --- .../src/attributes/types/strings/AbstractEMailAddress.ts | 5 ++--- packages/content/test/attributes/EmailAddress.test.ts | 8 ++++---- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/packages/content/src/attributes/types/strings/AbstractEMailAddress.ts b/packages/content/src/attributes/types/strings/AbstractEMailAddress.ts index 5c584796f..e8d6e3312 100644 --- a/packages/content/src/attributes/types/strings/AbstractEMailAddress.ts +++ b/packages/content/src/attributes/types/strings/AbstractEMailAddress.ts @@ -9,8 +9,7 @@ export abstract class AbstractEMailAddress extends AbstractString { min: 3, max: 254, regExp: new RegExp( - "^[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:[.][a-z0-9!#$%&'*+/=?^_`{|}~-]+){0,}@(?:[a-z0-9\u00c4\u00e4\u00d6\u00f6\u00dc\u00fc\u00df](?:[a-z\u00c4\u00e4\u00d6\u00f6\u00dc\u00fc\u00df0-9-]{0,61}[a-z\u00c4\u00e4\u00d6\u00f6\u00dc\u00fc\u00df0-9]){0,1}[.])+[a-z\u00c4\u00e4\u00d6\u00f6\u00dc\u00fc\u00df0-9](?:[a-z\u00c4\u00e4\u00d6\u00f6\u00dc\u00fc\u00df0-9-]{0,61}[a-z\u00c4\u00e4\u00d6\u00f6\u00dc\u00fc\u00df0-9])$", - "i" + /^[A-Za-z0-9!#$%&'*+/=?^_`{|}~-]+(?:[.][A-Za-z0-9!#$%&'*+/=?^_`{|}~-]+){0,}@(?:[A-Za-z0-9\u00c4\u00e4\u00d6\u00f6\u00dc\u00fc\u00df](?:[A-Za-z\u00c4\u00e4\u00d6\u00f6\u00dc\u00fc\u00df0-9-]{0,61}[A-Za-z\u00c4\u00e4\u00d6\u00f6\u00dc\u00fc\u00df0-9]){0,1}[.])+[A-Za-z\u00c4\u00e4\u00d6\u00f6\u00dc\u00fc\u00df0-9](?:[A-Za-z\u00c4\u00e4\u00d6\u00f6\u00dc\u00fc\u00df0-9-]{0,61}[A-Za-z\u00c4\u00e4\u00d6\u00f6\u00dc\u00fc\u00df0-9])$/ ) }) public override value: string; @@ -20,7 +19,7 @@ export abstract class AbstractEMailAddress extends AbstractString { min: 3, max: 254, pattern: - "^[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:[.][a-z0-9!#$%&'*+/=?^_`{|}~-]+){0,}@(?:[a-z0-9\u00c4\u00e4\u00d6\u00f6\u00dc\u00fc\u00df](?:[a-z\u00c4\u00e4\u00d6\u00f6\u00dc\u00fc\u00df0-9-]{0,61}[a-z\u00c4\u00e4\u00d6\u00f6\u00dc\u00fc\u00df0-9]){0,1}[.])+[a-z\u00c4\u00e4\u00d6\u00f6\u00dc\u00fc\u00df0-9](?:[a-z\u00c4\u00e4\u00d6\u00f6\u00dc\u00fc\u00df0-9-]{0,61}[a-z\u00c4\u00e4\u00d6\u00f6\u00dc\u00fc\u00df0-9])$/i" + "/^[A-Za-z0-9!#$%&'*+/=?^_`{|}~-]+(?:[.][A-Za-z0-9!#$%&'*+/=?^_`{|}~-]+){0,}@(?:[A-Za-z0-9\u00c4\u00e4\u00d6\u00f6\u00dc\u00fc\u00df](?:[A-Za-z\u00c4\u00e4\u00d6\u00f6\u00dc\u00fc\u00df0-9-]{0,61}[A-Za-z\u00c4\u00e4\u00d6\u00f6\u00dc\u00fc\u00df0-9]){0,1}[.])+[A-Za-z\u00c4\u00e4\u00d6\u00f6\u00dc\u00fc\u00df0-9](?:[A-Za-z\u00c4\u00e4\u00d6\u00f6\u00dc\u00fc\u00df0-9-]{0,61}[A-Za-z\u00c4\u00e4\u00d6\u00f6\u00dc\u00fc\u00df0-9])$/" }); } diff --git a/packages/content/test/attributes/EmailAddress.test.ts b/packages/content/test/attributes/EmailAddress.test.ts index d7ece286f..74a8eabb2 100644 --- a/packages/content/test/attributes/EmailAddress.test.ts +++ b/packages/content/test/attributes/EmailAddress.test.ts @@ -24,7 +24,7 @@ describe("creation of RepositoryAttributes of Attribute value type EMailAddress" new ParsingError( "EMailAddress", "value", - "Value does not match regular expression /^[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:[.][a-z0-9!#$%&'*+/=?^_`{|}~-]+){0,}@(?:[a-z0-9ÄäÖöÜüß](?:[a-zÄäÖöÜüß0-9-]{0,61}[a-zÄäÖöÜüß0-9]){0,1}[.])+[a-zÄäÖöÜüß0-9](?:[a-zÄäÖöÜüß0-9-]{0,61}[a-zÄäÖöÜüß0-9])$/i" + "Value does not match regular expression /^[A-Za-z0-9!#$%&'*+/=?^_`{|}~-]+(?:[.][A-Za-z0-9!#$%&'*+/=?^_`{|}~-]+){0,}@(?:[A-Za-z0-9\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df](?:[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9-]{0,61}[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9]){0,1}[.])+[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9](?:[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9-]{0,61}[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9])$/" ) ); }); @@ -38,7 +38,7 @@ describe("creation of RepositoryAttributes of Attribute value type EMailAddress" new ParsingError( "EMailAddress", "value", - "Value does not match regular expression /^[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:[.][a-z0-9!#$%&'*+/=?^_`{|}~-]+){0,}@(?:[a-z0-9ÄäÖöÜüß](?:[a-zÄäÖöÜüß0-9-]{0,61}[a-zÄäÖöÜüß0-9]){0,1}[.])+[a-zÄäÖöÜüß0-9](?:[a-zÄäÖöÜüß0-9-]{0,61}[a-zÄäÖöÜüß0-9])$/i" + "Value does not match regular expression /^[A-Za-z0-9!#$%&'*+/=?^_`{|}~-]+(?:[.][A-Za-z0-9!#$%&'*+/=?^_`{|}~-]+){0,}@(?:[A-Za-z0-9\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df](?:[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9-]{0,61}[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9]){0,1}[.])+[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9](?:[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9-]{0,61}[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9])$/" ) ); }); @@ -52,7 +52,7 @@ describe("creation of RepositoryAttributes of Attribute value type EMailAddress" new ParsingError( "EMailAddress", "value", - "Value does not match regular expression /^[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:[.][a-z0-9!#$%&'*+/=?^_`{|}~-]+){0,}@(?:[a-z0-9ÄäÖöÜüß](?:[a-zÄäÖöÜüß0-9-]{0,61}[a-zÄäÖöÜüß0-9]){0,1}[.])+[a-zÄäÖöÜüß0-9](?:[a-zÄäÖöÜüß0-9-]{0,61}[a-zÄäÖöÜüß0-9])$/i" + "Value does not match regular expression /^[A-Za-z0-9!#$%&'*+/=?^_`{|}~-]+(?:[.][A-Za-z0-9!#$%&'*+/=?^_`{|}~-]+){0,}@(?:[A-Za-z0-9\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df](?:[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9-]{0,61}[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9]){0,1}[.])+[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9](?:[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9-]{0,61}[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9])$/" ) ); }); @@ -66,7 +66,7 @@ describe("creation of RepositoryAttributes of Attribute value type EMailAddress" new ParsingError( "EMailAddress", "value", - "Value does not match regular expression /^[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:[.][a-z0-9!#$%&'*+/=?^_`{|}~-]+){0,}@(?:[a-z0-9ÄäÖöÜüß](?:[a-zÄäÖöÜüß0-9-]{0,61}[a-zÄäÖöÜüß0-9]){0,1}[.])+[a-zÄäÖöÜüß0-9](?:[a-zÄäÖöÜüß0-9-]{0,61}[a-zÄäÖöÜüß0-9])$/i" + "Value does not match regular expression /^[A-Za-z0-9!#$%&'*+/=?^_`{|}~-]+(?:[.][A-Za-z0-9!#$%&'*+/=?^_`{|}~-]+){0,}@(?:[A-Za-z0-9\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df](?:[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9-]{0,61}[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9]){0,1}[.])+[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9](?:[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9-]{0,61}[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9])$/" ) ); }); From 407b174a5a76974f4d492071e58b7f666b59fdac Mon Sep 17 00:00:00 2001 From: Ruth Di Giacomo Date: Wed, 15 May 2024 09:36:24 +0200 Subject: [PATCH 10/19] refactor: test for Website and AbstractURL --- .../src/attributes/types/strings/AbstractURL.ts | 4 ++-- packages/content/test/attributes/Website.test.ts | 14 ++++++++++---- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/packages/content/src/attributes/types/strings/AbstractURL.ts b/packages/content/src/attributes/types/strings/AbstractURL.ts index 7ea45cd81..326a702df 100644 --- a/packages/content/src/attributes/types/strings/AbstractURL.ts +++ b/packages/content/src/attributes/types/strings/AbstractURL.ts @@ -9,7 +9,7 @@ export abstract class AbstractURL extends AbstractString { max: 1024, regExp: new RegExp( // eslint-disable-next-line no-useless-escape - /^(?:|[A-Za-z]{3,9}:(?:\/\/)?|[:](?:\/\/)?|(?:\/\/))(?:(www[.])(?:[a-z0-9\u00c4\u00e4\u00d6\u00f6\u00dc\u00fc\u00df](?:[A-Za-z\u00c4\u00e4\u00d6\u00f6\u00dc\u00fc\u00df0-9-]{0,61}[A-Za-z\u00c4\u00e4\u00d6\u00f6\u00dc\u00fc\u00df0-9]){0,1}[.])|((?!www.)(?:[a-z0-9\u00c4\u00e4\u00d6\u00f6\u00dc\u00fc\u00df](?:[A-Za-z\u00c4\u00e4\u00d6\u00f6\u00dc\u00fc\u00df0-9-]{0,61}[A-Za-z\u00c4\u00e4\u00d6\u00f6\u00dc\u00fc\u00df0-9]){0,1}[.])))[A-Za-z\u00c4\u00e4\u00d6\u00f6\u00dc\u00fc\u00df0-9](?:[A-Za-z\u00c4\u00e4\u00d6\u00f6\u00dc\u00fc\u00df0-9-]{0,61}[A-Za-z\u00c4\u00e4\u00d6\u00f6\u00dc\u00fc\u00df0-9])(\:[0-9]+){0,}(?:[/][\w\u00c4\u00e4\u00d6\u00f6\u00dc\u00fc\u00df\-_?#@!\$&'\(\)\*\+,;=]{0,}){0,}$/ + /^(?:|[A-Za-z]{3,9}:(?:\/\/)?|[:](?:\/\/)?|(?:\/\/))(?:(www[.])(?:[a-z0-9\u00c4\u00e4\u00d6\u00f6\u00dc\u00fc\u00df](?:[A-Za-z\u00c4\u00e4\u00d6\u00f6\u00dc\u00fc\u00df0-9-]{0,61}[A-Za-z\u00c4\u00e4\u00d6\u00f6\u00dc\u00fc\u00df0-9]){0,1}[.])|((?!www.)(?:[a-z0-9\u00c4\u00e4\u00d6\u00f6\u00dc\u00fc\u00df](?:[A-Za-z\u00c4\u00e4\u00d6\u00f6\u00dc\u00fc\u00df0-9-]{0,61}[A-Za-z\u00c4\u00e4\u00d6\u00f6\u00dc\u00fc\u00df0-9]){0,1}[.])))[A-Za-z\u00c4\u00e4\u00d6\u00f6\u00dc\u00fc\u00df0-9](?:[A-Za-z\u00c4\u00e4\u00d6\u00f6\u00dc\u00fc\u00df0-9-]{0,61}[A-Za-z\u00c4\u00e4\u00d6\u00f6\u00dc\u00fc\u00df0-9])(\:[0-9]+){0,}(?:[/][\w\u00c4\u00e4\u00d6\u00f6\u00dc\u00fc\u00df\-_?#@!\$&'\(\)\*\+,;=%]{0,}){0,}$/ ) }) public override value: string; @@ -19,7 +19,7 @@ export abstract class AbstractURL extends AbstractString { min: 3, max: 1024, pattern: - "/^(?:|[A-Za-z]{3,9}:(?://)?|[:](?://)?|(?://))(?:(www[.])(?:[a-z0-9\u00c4\u00e4\u00d6\u00f6\u00dc\u00fc\u00df](?:[A-Za-z\u00c4\u00e4\u00d6\u00f6\u00dc\u00fc\u00df0-9-]{0,61}[A-Za-z\u00c4\u00e4\u00d6\u00f6\u00dc\u00fc\u00df0-9]){0,1}[.])|((?!www.)(?:[a-z0-9\u00c4\u00e4\u00d6\u00f6\u00dc\u00fc\u00df](?:[A-Za-z\u00c4\u00e4\u00d6\u00f6\u00dc\u00fc\u00df0-9-]{0,61}[A-Za-z\u00c4\u00e4\u00d6\u00f6\u00dc\u00fc\u00df0-9]){0,1}[.])))[A-Za-z\u00c4\u00e4\u00d6\u00f6\u00dc\u00fc\u00df0-9](?:[A-Za-z\u00c4\u00e4\u00d6\u00f6\u00dc\u00fc\u00df0-9-]{0,61}[A-Za-z\u00c4\u00e4\u00d6\u00f6\u00dc\u00fc\u00df0-9])(:[0-9]+){0,}(?:[/][w\u00c4\u00e4\u00d6\u00f6\u00dc\u00fc\u00df-_?#@!$&'()*+,;=]{0,}){0,}$/" + "/^(?:|[A-Za-z]{3,9}:(?://)?|[:](?://)?|(?://))(?:(www[.])(?:[a-z0-9\u00c4\u00e4\u00d6\u00f6\u00dc\u00fc\u00df](?:[A-Za-z\u00c4\u00e4\u00d6\u00f6\u00dc\u00fc\u00df0-9-]{0,61}[A-Za-z\u00c4\u00e4\u00d6\u00f6\u00dc\u00fc\u00df0-9]){0,1}[.])|((?!www.)(?:[a-z0-9\u00c4\u00e4\u00d6\u00f6\u00dc\u00fc\u00df](?:[A-Za-z\u00c4\u00e4\u00d6\u00f6\u00dc\u00fc\u00df0-9-]{0,61}[A-Za-z\u00c4\u00e4\u00d6\u00f6\u00dc\u00fc\u00df0-9]){0,1}[.])))[A-Za-z\u00c4\u00e4\u00d6\u00f6\u00dc\u00fc\u00df0-9](?:[A-Za-z\u00c4\u00e4\u00d6\u00f6\u00dc\u00fc\u00df0-9-]{0,61}[A-Za-z\u00c4\u00e4\u00d6\u00f6\u00dc\u00fc\u00df0-9])(:[0-9]+){0,}(?:[/][w\u00c4\u00e4\u00d6\u00f6\u00dc\u00fc\u00df-_?#@!$&'()*+,;=%]{0,}){0,}$/" }); } diff --git a/packages/content/test/attributes/Website.test.ts b/packages/content/test/attributes/Website.test.ts index e02ff47c2..5b44e8b23 100644 --- a/packages/content/test/attributes/Website.test.ts +++ b/packages/content/test/attributes/Website.test.ts @@ -34,6 +34,12 @@ describe("creation of RepositoryAttributes of Attribute value type Website", fun "https://enmeshed.de/blog/meilenstein-enmeshed-als-komponente-ablage-in-mein-bildungsraum-geht-in-die-testphase-der-beta-version/" ); }); + test("can create a RepositoryAttribute of Attribute value type Website with an encoded url", function () { + const validWebsite = Website.from({ + value: "https://inwind.test/%20it/" + }); + expect(validWebsite.value.toString()).toBe("https://inwind.test/%20it/"); + }); test("returns an error when trying to create an Attribute value type Website with a blank in the value for Website", function () { const invalidWebsiteCall = () => { Website.from({ @@ -44,7 +50,7 @@ describe("creation of RepositoryAttributes of Attribute value type Website", fun new ParsingError( "Website", "value", - "Value does not match regular expression /^(?:|[A-Za-z]{3,9}:(?:\\/\\/)?|[:](?:\\/\\/)?|(?:\\/\\/))(?:(www[.])(?:[a-z0-9\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df](?:[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9-]{0,61}[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9]){0,1}[.])|((?!www.)(?:[a-z0-9\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df](?:[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9-]{0,61}[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9]){0,1}[.])))[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9](?:[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9-]{0,61}[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9])(\\:[0-9]+){0,}(?:[/][\\w\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df\\-_?#@!\\$&'\\(\\)\\*\\+,;=]{0,}){0,}$/" + "Value does not match regular expression /^(?:|[A-Za-z]{3,9}:(?:\\/\\/)?|[:](?:\\/\\/)?|(?:\\/\\/))(?:(www[.])(?:[a-z0-9\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df](?:[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9-]{0,61}[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9]){0,1}[.])|((?!www.)(?:[a-z0-9\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df](?:[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9-]{0,61}[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9]){0,1}[.])))[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9](?:[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9-]{0,61}[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9])(\\:[0-9]+){0,}(?:[/][\\w\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df\\-_?#@!\\$&'\\(\\)\\*\\+,;=%]{0,}){0,}$/" ) ); }); @@ -58,7 +64,7 @@ describe("creation of RepositoryAttributes of Attribute value type Website", fun new ParsingError( "Website", "value", - "Value does not match regular expression /^(?:|[A-Za-z]{3,9}:(?:\\/\\/)?|[:](?:\\/\\/)?|(?:\\/\\/))(?:(www[.])(?:[a-z0-9\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df](?:[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9-]{0,61}[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9]){0,1}[.])|((?!www.)(?:[a-z0-9\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df](?:[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9-]{0,61}[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9]){0,1}[.])))[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9](?:[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9-]{0,61}[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9])(\\:[0-9]+){0,}(?:[/][\\w\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df\\-_?#@!\\$&'\\(\\)\\*\\+,;=]{0,}){0,}$/" + "Value does not match regular expression /^(?:|[A-Za-z]{3,9}:(?:\\/\\/)?|[:](?:\\/\\/)?|(?:\\/\\/))(?:(www[.])(?:[a-z0-9\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df](?:[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9-]{0,61}[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9]){0,1}[.])|((?!www.)(?:[a-z0-9\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df](?:[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9-]{0,61}[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9]){0,1}[.])))[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9](?:[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9-]{0,61}[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9])(\\:[0-9]+){0,}(?:[/][\\w\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df\\-_?#@!\\$&'\\(\\)\\*\\+,;=%]{0,}){0,}$/" ) ); }); @@ -72,7 +78,7 @@ describe("creation of RepositoryAttributes of Attribute value type Website", fun new ParsingError( "Website", "value", - "Value does not match regular expression /^(?:|[A-Za-z]{3,9}:(?:\\/\\/)?|[:](?:\\/\\/)?|(?:\\/\\/))(?:(www[.])(?:[a-z0-9\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df](?:[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9-]{0,61}[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9]){0,1}[.])|((?!www.)(?:[a-z0-9\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df](?:[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9-]{0,61}[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9]){0,1}[.])))[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9](?:[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9-]{0,61}[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9])(\\:[0-9]+){0,}(?:[/][\\w\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df\\-_?#@!\\$&'\\(\\)\\*\\+,;=]{0,}){0,}$/" + "Value does not match regular expression /^(?:|[A-Za-z]{3,9}:(?:\\/\\/)?|[:](?:\\/\\/)?|(?:\\/\\/))(?:(www[.])(?:[a-z0-9\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df](?:[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9-]{0,61}[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9]){0,1}[.])|((?!www.)(?:[a-z0-9\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df](?:[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9-]{0,61}[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9]){0,1}[.])))[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9](?:[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9-]{0,61}[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9])(\\:[0-9]+){0,}(?:[/][\\w\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df\\-_?#@!\\$&'\\(\\)\\*\\+,;=%]{0,}){0,}$/" ) ); }); @@ -86,7 +92,7 @@ describe("creation of RepositoryAttributes of Attribute value type Website", fun new ParsingError( "Website", "value", - "Value does not match regular expression /^(?:|[A-Za-z]{3,9}:(?:\\/\\/)?|[:](?:\\/\\/)?|(?:\\/\\/))(?:(www[.])(?:[a-z0-9\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df](?:[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9-]{0,61}[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9]){0,1}[.])|((?!www.)(?:[a-z0-9\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df](?:[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9-]{0,61}[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9]){0,1}[.])))[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9](?:[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9-]{0,61}[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9])(\\:[0-9]+){0,}(?:[/][\\w\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df\\-_?#@!\\$&'\\(\\)\\*\\+,;=]{0,}){0,}$/" + "Value does not match regular expression /^(?:|[A-Za-z]{3,9}:(?:\\/\\/)?|[:](?:\\/\\/)?|(?:\\/\\/))(?:(www[.])(?:[a-z0-9\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df](?:[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9-]{0,61}[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9]){0,1}[.])|((?!www.)(?:[a-z0-9\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df](?:[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9-]{0,61}[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9]){0,1}[.])))[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9](?:[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9-]{0,61}[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9])(\\:[0-9]+){0,}(?:[/][\\w\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df\\-_?#@!\\$&'\\(\\)\\*\\+,;=%]{0,}){0,}$/" ) ); }); From 24b3c148274677ec822605f790bf794339510c06 Mon Sep 17 00:00:00 2001 From: Ruth Di Giacomo Date: Thu, 16 May 2024 09:39:30 +0200 Subject: [PATCH 11/19] refactor: name and AbstractURL without escape --- .../src/attributes/types/strings/AbstractURL.ts | 5 ++--- .../{EmailAddress.test.ts => EMailAddress.test.ts} | 0 packages/content/test/attributes/Website.test.ts | 14 ++++++++++---- 3 files changed, 12 insertions(+), 7 deletions(-) rename packages/content/test/attributes/{EmailAddress.test.ts => EMailAddress.test.ts} (100%) diff --git a/packages/content/src/attributes/types/strings/AbstractURL.ts b/packages/content/src/attributes/types/strings/AbstractURL.ts index 326a702df..83d27923f 100644 --- a/packages/content/src/attributes/types/strings/AbstractURL.ts +++ b/packages/content/src/attributes/types/strings/AbstractURL.ts @@ -8,8 +8,7 @@ export abstract class AbstractURL extends AbstractString { min: 3, max: 1024, regExp: new RegExp( - // eslint-disable-next-line no-useless-escape - /^(?:|[A-Za-z]{3,9}:(?:\/\/)?|[:](?:\/\/)?|(?:\/\/))(?:(www[.])(?:[a-z0-9\u00c4\u00e4\u00d6\u00f6\u00dc\u00fc\u00df](?:[A-Za-z\u00c4\u00e4\u00d6\u00f6\u00dc\u00fc\u00df0-9-]{0,61}[A-Za-z\u00c4\u00e4\u00d6\u00f6\u00dc\u00fc\u00df0-9]){0,1}[.])|((?!www.)(?:[a-z0-9\u00c4\u00e4\u00d6\u00f6\u00dc\u00fc\u00df](?:[A-Za-z\u00c4\u00e4\u00d6\u00f6\u00dc\u00fc\u00df0-9-]{0,61}[A-Za-z\u00c4\u00e4\u00d6\u00f6\u00dc\u00fc\u00df0-9]){0,1}[.])))[A-Za-z\u00c4\u00e4\u00d6\u00f6\u00dc\u00fc\u00df0-9](?:[A-Za-z\u00c4\u00e4\u00d6\u00f6\u00dc\u00fc\u00df0-9-]{0,61}[A-Za-z\u00c4\u00e4\u00d6\u00f6\u00dc\u00fc\u00df0-9])(\:[0-9]+){0,}(?:[/][\w\u00c4\u00e4\u00d6\u00f6\u00dc\u00fc\u00df\-_?#@!\$&'\(\)\*\+,;=%]{0,}){0,}$/ + /^(?:|[A-Za-z]{3,9}:(?:[/][/])?|[:](?:[/][/])?|(?:[/][/]))(?:(www[.])(?:[A-Za-z0-9\u00c4\u00e4\u00d6\u00f6\u00dc\u00fc\u00df](?:[A-Za-z\u00c4\u00e4\u00d6\u00f6\u00dc\u00fc\u00df0-9-]{0,61}[A-Za-z\u00c4\u00e4\u00d6\u00f6\u00dc\u00fc\u00df0-9]){0,1}[.])|((?!www[.])(?:[A-Za-z0-9\u00c4\u00e4\u00d6\u00f6\u00dc\u00fc\u00df](?:[A-Za-z\u00c4\u00e4\u00d6\u00f6\u00dc\u00fc\u00df0-9-]{0,61}[A-Za-z\u00c4\u00e4\u00d6\u00f6\u00dc\u00fc\u00df0-9]){0,1}[.])))[A-Za-z\u00c4\u00e4\u00d6\u00f6\u00dc\u00fc\u00df0-9](?:[A-Za-z\u00c4\u00e4\u00d6\u00f6\u00dc\u00fc\u00df0-9-]{0,61}[A-Za-z\u00c4\u00e4\u00d6\u00f6\u00dc\u00fc\u00df0-9])(?:[:][0-9]+){0,}(?:[/][A-Za-z\u00c4\u00e4\u00d6\u00f6\u00dc\u00fc\u00df0-9?#@!$&'()*+/,;=%-]{0,}){0,}$/ ) }) public override value: string; @@ -19,7 +18,7 @@ export abstract class AbstractURL extends AbstractString { min: 3, max: 1024, pattern: - "/^(?:|[A-Za-z]{3,9}:(?://)?|[:](?://)?|(?://))(?:(www[.])(?:[a-z0-9\u00c4\u00e4\u00d6\u00f6\u00dc\u00fc\u00df](?:[A-Za-z\u00c4\u00e4\u00d6\u00f6\u00dc\u00fc\u00df0-9-]{0,61}[A-Za-z\u00c4\u00e4\u00d6\u00f6\u00dc\u00fc\u00df0-9]){0,1}[.])|((?!www.)(?:[a-z0-9\u00c4\u00e4\u00d6\u00f6\u00dc\u00fc\u00df](?:[A-Za-z\u00c4\u00e4\u00d6\u00f6\u00dc\u00fc\u00df0-9-]{0,61}[A-Za-z\u00c4\u00e4\u00d6\u00f6\u00dc\u00fc\u00df0-9]){0,1}[.])))[A-Za-z\u00c4\u00e4\u00d6\u00f6\u00dc\u00fc\u00df0-9](?:[A-Za-z\u00c4\u00e4\u00d6\u00f6\u00dc\u00fc\u00df0-9-]{0,61}[A-Za-z\u00c4\u00e4\u00d6\u00f6\u00dc\u00fc\u00df0-9])(:[0-9]+){0,}(?:[/][w\u00c4\u00e4\u00d6\u00f6\u00dc\u00fc\u00df-_?#@!$&'()*+,;=%]{0,}){0,}$/" + "/^(?:|[A-Za-z]{3,9}:(?:[/][/])?|[:](?:[/][/])?|(?:[/][/]))(?:(www[.])(?:[A-Za-z0-9\u00c4\u00e4\u00d6\u00f6\u00dc\u00fc\u00df](?:[A-Za-z\u00c4\u00e4\u00d6\u00f6\u00dc\u00fc\u00df0-9-]{0,61}[A-Za-z\u00c4\u00e4\u00d6\u00f6\u00dc\u00fc\u00df0-9]){0,1}[.])|((?!www[.])(?:[A-Za-z0-9\u00c4\u00e4\u00d6\u00f6\u00dc\u00fc\u00df](?:[A-Za-z\u00c4\u00e4\u00d6\u00f6\u00dc\u00fc\u00df0-9-]{0,61}[A-Za-z\u00c4\u00e4\u00d6\u00f6\u00dc\u00fc\u00df0-9]){0,1}[.])))[A-Za-z\u00c4\u00e4\u00d6\u00f6\u00dc\u00fc\u00df0-9](?:[A-Za-z\u00c4\u00e4\u00d6\u00f6\u00dc\u00fc\u00df0-9-]{0,61}[A-Za-z\u00c4\u00e4\u00d6\u00f6\u00dc\u00fc\u00df0-9])(?:[:][0-9]+){0,}(?:[/][A-Za-z\u00c4\u00e4\u00d6\u00f6\u00dc\u00fc\u00df0-9?#@!$&'()*+/,;=%-]{0,}){0,}$/" }); } diff --git a/packages/content/test/attributes/EmailAddress.test.ts b/packages/content/test/attributes/EMailAddress.test.ts similarity index 100% rename from packages/content/test/attributes/EmailAddress.test.ts rename to packages/content/test/attributes/EMailAddress.test.ts diff --git a/packages/content/test/attributes/Website.test.ts b/packages/content/test/attributes/Website.test.ts index 5b44e8b23..fd3d1655e 100644 --- a/packages/content/test/attributes/Website.test.ts +++ b/packages/content/test/attributes/Website.test.ts @@ -40,6 +40,12 @@ describe("creation of RepositoryAttributes of Attribute value type Website", fun }); expect(validWebsite.value.toString()).toBe("https://inwind.test/%20it/"); }); + test("can create a RepositoryAttribute of Attribute value type Website with a port ", function () { + const validWebsite = Website.from({ + value: "https://example.org:8080/mein/ordner/bericht" + }); + expect(validWebsite.value.toString()).toBe("https://example.org:8080/mein/ordner/bericht"); + }); test("returns an error when trying to create an Attribute value type Website with a blank in the value for Website", function () { const invalidWebsiteCall = () => { Website.from({ @@ -50,7 +56,7 @@ describe("creation of RepositoryAttributes of Attribute value type Website", fun new ParsingError( "Website", "value", - "Value does not match regular expression /^(?:|[A-Za-z]{3,9}:(?:\\/\\/)?|[:](?:\\/\\/)?|(?:\\/\\/))(?:(www[.])(?:[a-z0-9\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df](?:[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9-]{0,61}[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9]){0,1}[.])|((?!www.)(?:[a-z0-9\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df](?:[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9-]{0,61}[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9]){0,1}[.])))[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9](?:[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9-]{0,61}[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9])(\\:[0-9]+){0,}(?:[/][\\w\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df\\-_?#@!\\$&'\\(\\)\\*\\+,;=%]{0,}){0,}$/" + "Value does not match regular expression /^(?:|[A-Za-z]{3,9}:(?:[/][/])?|[:](?:[/][/])?|(?:[/][/]))(?:(www[.])(?:[A-Za-z0-9\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df](?:[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9-]{0,61}[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9]){0,1}[.])|((?!www[.])(?:[A-Za-z0-9\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df](?:[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9-]{0,61}[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9]){0,1}[.])))[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9](?:[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9-]{0,61}[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9])(?:[:][0-9]+){0,}(?:[/][A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9?#@!$&'()*+/,;=%-]{0,}){0,}$/" ) ); }); @@ -64,7 +70,7 @@ describe("creation of RepositoryAttributes of Attribute value type Website", fun new ParsingError( "Website", "value", - "Value does not match regular expression /^(?:|[A-Za-z]{3,9}:(?:\\/\\/)?|[:](?:\\/\\/)?|(?:\\/\\/))(?:(www[.])(?:[a-z0-9\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df](?:[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9-]{0,61}[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9]){0,1}[.])|((?!www.)(?:[a-z0-9\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df](?:[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9-]{0,61}[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9]){0,1}[.])))[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9](?:[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9-]{0,61}[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9])(\\:[0-9]+){0,}(?:[/][\\w\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df\\-_?#@!\\$&'\\(\\)\\*\\+,;=%]{0,}){0,}$/" + "Value does not match regular expression /^(?:|[A-Za-z]{3,9}:(?:[/][/])?|[:](?:[/][/])?|(?:[/][/]))(?:(www[.])(?:[A-Za-z0-9\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df](?:[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9-]{0,61}[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9]){0,1}[.])|((?!www[.])(?:[A-Za-z0-9\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df](?:[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9-]{0,61}[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9]){0,1}[.])))[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9](?:[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9-]{0,61}[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9])(?:[:][0-9]+){0,}(?:[/][A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9?#@!$&'()*+/,;=%-]{0,}){0,}$/" ) ); }); @@ -78,7 +84,7 @@ describe("creation of RepositoryAttributes of Attribute value type Website", fun new ParsingError( "Website", "value", - "Value does not match regular expression /^(?:|[A-Za-z]{3,9}:(?:\\/\\/)?|[:](?:\\/\\/)?|(?:\\/\\/))(?:(www[.])(?:[a-z0-9\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df](?:[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9-]{0,61}[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9]){0,1}[.])|((?!www.)(?:[a-z0-9\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df](?:[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9-]{0,61}[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9]){0,1}[.])))[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9](?:[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9-]{0,61}[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9])(\\:[0-9]+){0,}(?:[/][\\w\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df\\-_?#@!\\$&'\\(\\)\\*\\+,;=%]{0,}){0,}$/" + "Value does not match regular expression /^(?:|[A-Za-z]{3,9}:(?:[/][/])?|[:](?:[/][/])?|(?:[/][/]))(?:(www[.])(?:[A-Za-z0-9\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df](?:[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9-]{0,61}[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9]){0,1}[.])|((?!www[.])(?:[A-Za-z0-9\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df](?:[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9-]{0,61}[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9]){0,1}[.])))[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9](?:[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9-]{0,61}[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9])(?:[:][0-9]+){0,}(?:[/][A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9?#@!$&'()*+/,;=%-]{0,}){0,}$/" ) ); }); @@ -92,7 +98,7 @@ describe("creation of RepositoryAttributes of Attribute value type Website", fun new ParsingError( "Website", "value", - "Value does not match regular expression /^(?:|[A-Za-z]{3,9}:(?:\\/\\/)?|[:](?:\\/\\/)?|(?:\\/\\/))(?:(www[.])(?:[a-z0-9\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df](?:[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9-]{0,61}[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9]){0,1}[.])|((?!www.)(?:[a-z0-9\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df](?:[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9-]{0,61}[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9]){0,1}[.])))[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9](?:[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9-]{0,61}[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9])(\\:[0-9]+){0,}(?:[/][\\w\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df\\-_?#@!\\$&'\\(\\)\\*\\+,;=%]{0,}){0,}$/" + "Value does not match regular expression /^(?:|[A-Za-z]{3,9}:(?:[/][/])?|[:](?:[/][/])?|(?:[/][/]))(?:(www[.])(?:[A-Za-z0-9\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df](?:[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9-]{0,61}[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9]){0,1}[.])|((?!www[.])(?:[A-Za-z0-9\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df](?:[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9-]{0,61}[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9]){0,1}[.])))[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9](?:[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9-]{0,61}[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9])(?:[:][0-9]+){0,}(?:[/][A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9?#@!$&'()*+/,;=%-]{0,}){0,}$/" ) ); }); From a8fa603e9e0ded61ce97633e16d05531b95a9422 Mon Sep 17 00:00:00 2001 From: Ruth Di Giacomo Date: Wed, 5 Jun 2024 10:32:12 +0200 Subject: [PATCH 12/19] refactor: Change Tests and RegExp --- .../types/strings/AbstractEMailAddress.ts | 6 +- .../attributes/types/strings/AbstractURL.ts | 4 +- .../test/attributes/EMailAddress.test.ts | 71 +++-------- .../content/test/attributes/Website.test.ts | 111 ++++-------------- 4 files changed, 41 insertions(+), 151 deletions(-) diff --git a/packages/content/src/attributes/types/strings/AbstractEMailAddress.ts b/packages/content/src/attributes/types/strings/AbstractEMailAddress.ts index e8d6e3312..89b71021b 100644 --- a/packages/content/src/attributes/types/strings/AbstractEMailAddress.ts +++ b/packages/content/src/attributes/types/strings/AbstractEMailAddress.ts @@ -4,12 +4,13 @@ import { AbstractString } from "../AbstractString"; export abstract class AbstractEMailAddress extends AbstractString { // from https://html.spec.whatwg.org/multipage/input.html#valid-e-mail-address + @serialize() @validate({ min: 3, max: 254, regExp: new RegExp( - /^[A-Za-z0-9!#$%&'*+/=?^_`{|}~-]+(?:[.][A-Za-z0-9!#$%&'*+/=?^_`{|}~-]+){0,}@(?:[A-Za-z0-9\u00c4\u00e4\u00d6\u00f6\u00dc\u00fc\u00df](?:[A-Za-z\u00c4\u00e4\u00d6\u00f6\u00dc\u00fc\u00df0-9-]{0,61}[A-Za-z\u00c4\u00e4\u00d6\u00f6\u00dc\u00fc\u00df0-9]){0,1}[.])+[A-Za-z\u00c4\u00e4\u00d6\u00f6\u00dc\u00fc\u00df0-9](?:[A-Za-z\u00c4\u00e4\u00d6\u00f6\u00dc\u00fc\u00df0-9-]{0,61}[A-Za-z\u00c4\u00e4\u00d6\u00f6\u00dc\u00fc\u00df0-9])$/ + /^[A-Za-z0-9!#$%&'*+/=?^_`{|}~-]+(?:[.][A-Za-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[A-Za-z0-9ÄäÖöÜüß](?:[A-Za-z0-9ÄäÖöÜüß-]{0,61}[A-Za-z0-9ÄäÖöÜüß])?[.])+[A-Za-z0-9ÄäÖöÜüß](?:[A-Za-z0-9ÄäÖöÜüß-]{0,61}[A-Za-z0-9ÄäÖöÜüß])$/ ) }) public override value: string; @@ -18,8 +19,7 @@ export abstract class AbstractEMailAddress extends AbstractString { return super.valueHints.copyWith({ min: 3, max: 254, - pattern: - "/^[A-Za-z0-9!#$%&'*+/=?^_`{|}~-]+(?:[.][A-Za-z0-9!#$%&'*+/=?^_`{|}~-]+){0,}@(?:[A-Za-z0-9\u00c4\u00e4\u00d6\u00f6\u00dc\u00fc\u00df](?:[A-Za-z\u00c4\u00e4\u00d6\u00f6\u00dc\u00fc\u00df0-9-]{0,61}[A-Za-z\u00c4\u00e4\u00d6\u00f6\u00dc\u00fc\u00df0-9]){0,1}[.])+[A-Za-z\u00c4\u00e4\u00d6\u00f6\u00dc\u00fc\u00df0-9](?:[A-Za-z\u00c4\u00e4\u00d6\u00f6\u00dc\u00fc\u00df0-9-]{0,61}[A-Za-z\u00c4\u00e4\u00d6\u00f6\u00dc\u00fc\u00df0-9])$/" + pattern: String(RegExp) }); } diff --git a/packages/content/src/attributes/types/strings/AbstractURL.ts b/packages/content/src/attributes/types/strings/AbstractURL.ts index 83d27923f..92fc03553 100644 --- a/packages/content/src/attributes/types/strings/AbstractURL.ts +++ b/packages/content/src/attributes/types/strings/AbstractURL.ts @@ -8,7 +8,7 @@ export abstract class AbstractURL extends AbstractString { min: 3, max: 1024, regExp: new RegExp( - /^(?:|[A-Za-z]{3,9}:(?:[/][/])?|[:](?:[/][/])?|(?:[/][/]))(?:(www[.])(?:[A-Za-z0-9\u00c4\u00e4\u00d6\u00f6\u00dc\u00fc\u00df](?:[A-Za-z\u00c4\u00e4\u00d6\u00f6\u00dc\u00fc\u00df0-9-]{0,61}[A-Za-z\u00c4\u00e4\u00d6\u00f6\u00dc\u00fc\u00df0-9]){0,1}[.])|((?!www[.])(?:[A-Za-z0-9\u00c4\u00e4\u00d6\u00f6\u00dc\u00fc\u00df](?:[A-Za-z\u00c4\u00e4\u00d6\u00f6\u00dc\u00fc\u00df0-9-]{0,61}[A-Za-z\u00c4\u00e4\u00d6\u00f6\u00dc\u00fc\u00df0-9]){0,1}[.])))[A-Za-z\u00c4\u00e4\u00d6\u00f6\u00dc\u00fc\u00df0-9](?:[A-Za-z\u00c4\u00e4\u00d6\u00f6\u00dc\u00fc\u00df0-9-]{0,61}[A-Za-z\u00c4\u00e4\u00d6\u00f6\u00dc\u00fc\u00df0-9])(?:[:][0-9]+){0,}(?:[/][A-Za-z\u00c4\u00e4\u00d6\u00f6\u00dc\u00fc\u00df0-9?#@!$&'()*+/,;=%-]{0,}){0,}$/ + /^([A-Za-z]{3,9}[:]([/][/])?|[:]([/][/])?|([/][/]))?((www[.])([A-Za-z0-9ÄäÖöÜüß]([A-Za-zÄäÖöÜüß0-9-]{0,61}[A-Za-zÄäÖöÜüß0-9])?[.])+|((?!www[.])([A-Za-z0-9ÄäÖöÜüß]([A-Za-zÄäÖöÜüß0-9-]{0,61}[A-Za-zÄäÖöÜüß0-9])?[.]))([A-Za-z0-9ÄäÖöÜüß]([A-Za-zÄäÖöÜüß0-9-]{0,61}[A-Za-zÄäÖöÜüß0-9])?[.])*)[A-Za-zÄäÖöÜüß0-9]([A-Za-zÄäÖöÜüß0-9-]{0,61}[A-Za-zÄäÖöÜüß0-9])([:][0-9]+)*([/][A-Za-zÄäÖöÜüß0-9?#@!$&'()*+,;=%-]*)*$/ ) }) public override value: string; @@ -18,7 +18,7 @@ export abstract class AbstractURL extends AbstractString { min: 3, max: 1024, pattern: - "/^(?:|[A-Za-z]{3,9}:(?:[/][/])?|[:](?:[/][/])?|(?:[/][/]))(?:(www[.])(?:[A-Za-z0-9\u00c4\u00e4\u00d6\u00f6\u00dc\u00fc\u00df](?:[A-Za-z\u00c4\u00e4\u00d6\u00f6\u00dc\u00fc\u00df0-9-]{0,61}[A-Za-z\u00c4\u00e4\u00d6\u00f6\u00dc\u00fc\u00df0-9]){0,1}[.])|((?!www[.])(?:[A-Za-z0-9\u00c4\u00e4\u00d6\u00f6\u00dc\u00fc\u00df](?:[A-Za-z\u00c4\u00e4\u00d6\u00f6\u00dc\u00fc\u00df0-9-]{0,61}[A-Za-z\u00c4\u00e4\u00d6\u00f6\u00dc\u00fc\u00df0-9]){0,1}[.])))[A-Za-z\u00c4\u00e4\u00d6\u00f6\u00dc\u00fc\u00df0-9](?:[A-Za-z\u00c4\u00e4\u00d6\u00f6\u00dc\u00fc\u00df0-9-]{0,61}[A-Za-z\u00c4\u00e4\u00d6\u00f6\u00dc\u00fc\u00df0-9])(?:[:][0-9]+){0,}(?:[/][A-Za-z\u00c4\u00e4\u00d6\u00f6\u00dc\u00fc\u00df0-9?#@!$&'()*+/,;=%-]{0,}){0,}$/" + "/^([A-Za-z]{3,9}[:]([/][/])?|[:]([/][/])?|([/][/]))?((www[.])([A-Za-z0-9ÄäÖöÜüß]([A-Za-zÄäÖöÜüß0-9-]{0,61}[A-Za-zÄäÖöÜüß0-9])?[.])+|((?!www[.])([A-Za-z0-9ÄäÖöÜüß]([A-Za-zÄäÖöÜüß0-9-]{0,61}[A-Za-zÄäÖöÜüß0-9])?[.]))([A-Za-z0-9ÄäÖöÜüß]([A-Za-zÄäÖöÜüß0-9-]{0,61}[A-Za-zÄäÖöÜüß0-9])?[.])*)[A-Za-zÄäÖöÜüß0-9]([A-Za-zÄäÖöÜüß0-9-]{0,61}[A-Za-zÄäÖöÜüß0-9])([:][0-9]+)*([/][A-Za-zÄäÖöÜüß0-9?#@!$&'()*+,;=%-]*)*$/" }); } diff --git a/packages/content/test/attributes/EMailAddress.test.ts b/packages/content/test/attributes/EMailAddress.test.ts index 74a8eabb2..2454a1855 100644 --- a/packages/content/test/attributes/EMailAddress.test.ts +++ b/packages/content/test/attributes/EMailAddress.test.ts @@ -1,72 +1,29 @@ import { ParsingError } from "@js-soft/ts-serval"; import { EMailAddress } from "../../src"; -describe("creation of RepositoryAttributes of Attribute value type EMailAddress", function () { - test("can create a RepositoryAttribute of Attribute value type EMailAddress", function () { - const validEMailAddress = EMailAddress.from({ - value: "peter123@inwind.it" - }); - expect(validEMailAddress.value.toString()).toBe("peter123@inwind.it"); - }); - test("can create a RepositoryAttribute of Attribute value type EMailAddress with the German 'ä' in its domain", function () { - const validEMailAddress = EMailAddress.from({ - value: "peter123@inwänd.it" - }); - expect(validEMailAddress.value.toString()).toBe("peter123@inwänd.it"); - }); - test("returns an error when trying to create an Attribute value type EMailAddress with a blank in the value for EMailAddress", function () { - const invalidEMailAddressCall = () => { - EMailAddress.from({ - value: "Hugo Becker@gmx.de" - }); - }; - expect(invalidEMailAddressCall).toThrow( - new ParsingError( - "EMailAddress", - "value", - "Value does not match regular expression /^[A-Za-z0-9!#$%&'*+/=?^_`{|}~-]+(?:[.][A-Za-z0-9!#$%&'*+/=?^_`{|}~-]+){0,}@(?:[A-Za-z0-9\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df](?:[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9-]{0,61}[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9]){0,1}[.])+[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9](?:[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9-]{0,61}[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9])$/" - ) - ); - }); - test("returns an error when trying to create an Attribute value type EMailAddress without the right ending in the value for EMailAddress", function () { - const invalidEMailAddressCall = () => { - EMailAddress.from({ - value: "Becker@gmx" - }); - }; - expect(invalidEMailAddressCall).toThrow( - new ParsingError( - "EMailAddress", - "value", - "Value does not match regular expression /^[A-Za-z0-9!#$%&'*+/=?^_`{|}~-]+(?:[.][A-Za-z0-9!#$%&'*+/=?^_`{|}~-]+){0,}@(?:[A-Za-z0-9\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df](?:[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9-]{0,61}[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9]){0,1}[.])+[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9](?:[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9-]{0,61}[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9])$/" - ) - ); - }); - test("returns an error when trying to create an Attribute value type EMailAddress with a domain which ends with a - because this is not allowed for domains.", function () { - const invalidEMailAddressCall = () => { - EMailAddress.from({ - value: "Becker@gmx-.de" - }); - }; - expect(invalidEMailAddressCall).toThrow( - new ParsingError( - "EMailAddress", - "value", - "Value does not match regular expression /^[A-Za-z0-9!#$%&'*+/=?^_`{|}~-]+(?:[.][A-Za-z0-9!#$%&'*+/=?^_`{|}~-]+){0,}@(?:[A-Za-z0-9\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df](?:[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9-]{0,61}[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9]){0,1}[.])+[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9](?:[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9-]{0,61}[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9])$/" - ) - ); +describe("Test valid EMailAdresses", () => { + const validEMailAddresses = ["peter123@inwind.it", "peter123@inwänd.it"]; + + test.each(validEMailAddresses)("EMail %s is recognized as valid", (email) => { + const validEMailAddress = EMailAddress.from({ value: email }); + expect(validEMailAddress.value.toString()).toBe(email); }); - test("returns an error when trying to create an Attribute value type EMailAddress with a domain which begins with a - because this is not allowed for domains.", function () { +}); + +describe("Test invalid EMailAdresses", () => { + const invalidEMailAddresses = ["Hugo Becker@gmx.de", "Becker@gmx", "Becker@gmx-.de", "Becker@gmx-.de", ".Becker@gmx.de", "test@.address", "test@test..address"]; + + test.each(invalidEMailAddresses)("EMail %s is recognized as invalid", (email) => { const invalidEMailAddressCall = () => { EMailAddress.from({ - value: "Becker@-gmx.de" + value: email }); }; expect(invalidEMailAddressCall).toThrow( new ParsingError( "EMailAddress", "value", - "Value does not match regular expression /^[A-Za-z0-9!#$%&'*+/=?^_`{|}~-]+(?:[.][A-Za-z0-9!#$%&'*+/=?^_`{|}~-]+){0,}@(?:[A-Za-z0-9\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df](?:[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9-]{0,61}[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9]){0,1}[.])+[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9](?:[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9-]{0,61}[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9])$/" + "Value does not match regular expression /^[A-Za-z0-9!#$%&'*+/=?^_`{|}~-]+(?:[.][A-Za-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[A-Za-z0-9ÄäÖöÜüß](?:[A-Za-z0-9ÄäÖöÜüß-]{0,61}[A-Za-z0-9ÄäÖöÜüß])?[.])+[A-Za-z0-9ÄäÖöÜüß](?:[A-Za-z0-9ÄäÖöÜüß-]{0,61}[A-Za-z0-9ÄäÖöÜüß])$/" ) ); }); diff --git a/packages/content/test/attributes/Website.test.ts b/packages/content/test/attributes/Website.test.ts index fd3d1655e..131057236 100644 --- a/packages/content/test/attributes/Website.test.ts +++ b/packages/content/test/attributes/Website.test.ts @@ -1,104 +1,37 @@ import { ParsingError } from "@js-soft/ts-serval"; import { Website } from "../../src"; -describe("creation of RepositoryAttributes of Attribute value type Website", function () { - test("can create a RepositoryAttribute of Attribute value type Website with the beginning www.", function () { - const validWebsite = Website.from({ - value: "www.inwind.it" - }); - expect(validWebsite.value.toString()).toBe("www.inwind.it"); - }); - test("can create a RepositoryAttribute of Attribute value type Website", function () { - const validWebsite = Website.from({ - value: "https://inwind.it" - }); - expect(validWebsite.value.toString()).toBe("https://inwind.it"); - }); - test("can create a RepositoryAttribute of Attribute value type Website with the German 'ä' in its domain", function () { - const validWebsite = Website.from({ - value: "https://inwänd.it" - }); - expect(validWebsite.value.toString()).toBe("https://inwänd.it"); - }); - test("can create a RepositoryAttribute of Attribute value type Website without www.", function () { - const validWebsite = Website.from({ - value: "//google.it" - }); - expect(validWebsite.value.toString()).toBe("//google.it"); - }); - test("can create a RepositoryAttribute of Attribute value type Website with an enhanced path", function () { - const validWebsite = Website.from({ - value: "https://enmeshed.de/blog/meilenstein-enmeshed-als-komponente-ablage-in-mein-bildungsraum-geht-in-die-testphase-der-beta-version/" - }); - expect(validWebsite.value.toString()).toBe( - "https://enmeshed.de/blog/meilenstein-enmeshed-als-komponente-ablage-in-mein-bildungsraum-geht-in-die-testphase-der-beta-version/" - ); - }); - test("can create a RepositoryAttribute of Attribute value type Website with an encoded url", function () { - const validWebsite = Website.from({ - value: "https://inwind.test/%20it/" - }); - expect(validWebsite.value.toString()).toBe("https://inwind.test/%20it/"); - }); - test("can create a RepositoryAttribute of Attribute value type Website with a port ", function () { - const validWebsite = Website.from({ - value: "https://example.org:8080/mein/ordner/bericht" - }); - expect(validWebsite.value.toString()).toBe("https://example.org:8080/mein/ordner/bericht"); - }); - test("returns an error when trying to create an Attribute value type Website with a blank in the value for Website", function () { - const invalidWebsiteCall = () => { - Website.from({ - value: "https://inwind.test it" - }); - }; - expect(invalidWebsiteCall).toThrow( - new ParsingError( - "Website", - "value", - "Value does not match regular expression /^(?:|[A-Za-z]{3,9}:(?:[/][/])?|[:](?:[/][/])?|(?:[/][/]))(?:(www[.])(?:[A-Za-z0-9\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df](?:[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9-]{0,61}[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9]){0,1}[.])|((?!www[.])(?:[A-Za-z0-9\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df](?:[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9-]{0,61}[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9]){0,1}[.])))[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9](?:[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9-]{0,61}[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9])(?:[:][0-9]+){0,}(?:[/][A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9?#@!$&'()*+/,;=%-]{0,}){0,}$/" - ) - ); - }); - test("returns an error when trying to create an Attribute value type Website without the right ending when it starts with www.", function () { - const invalidWebsiteCall = () => { - Website.from({ - value: "www.google" - }); - }; - expect(invalidWebsiteCall).toThrow( - new ParsingError( - "Website", - "value", - "Value does not match regular expression /^(?:|[A-Za-z]{3,9}:(?:[/][/])?|[:](?:[/][/])?|(?:[/][/]))(?:(www[.])(?:[A-Za-z0-9\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df](?:[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9-]{0,61}[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9]){0,1}[.])|((?!www[.])(?:[A-Za-z0-9\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df](?:[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9-]{0,61}[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9]){0,1}[.])))[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9](?:[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9-]{0,61}[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9])(?:[:][0-9]+){0,}(?:[/][A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9?#@!$&'()*+/,;=%-]{0,}){0,}$/" - ) - ); - }); - test("returns an error when trying to create an Attribute value type Website with a domain which ends with a - because this is not allowed for domains.", function () { - const invalidWebsiteCall = () => { - Website.from({ - value: "google-.de" - }); - }; - expect(invalidWebsiteCall).toThrow( - new ParsingError( - "Website", - "value", - "Value does not match regular expression /^(?:|[A-Za-z]{3,9}:(?:[/][/])?|[:](?:[/][/])?|(?:[/][/]))(?:(www[.])(?:[A-Za-z0-9\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df](?:[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9-]{0,61}[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9]){0,1}[.])|((?!www[.])(?:[A-Za-z0-9\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df](?:[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9-]{0,61}[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9]){0,1}[.])))[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9](?:[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9-]{0,61}[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9])(?:[:][0-9]+){0,}(?:[/][A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9?#@!$&'()*+/,;=%-]{0,}){0,}$/" - ) - ); +describe("Test valid URLs", () => { + const validUrls = [ + "www.google.com", + "https://döner.cooking", + "http://inwind.it", + "//google.it", + "https://enmeshed.de/blog/meilenstein-enmeshed-als-komponente-ablage-in-mein-bildungsraum-geht-in-die-testphase-der-beta-version/", + "www.foo.www.www.enmeshed.eu", + "https://example.org:8080/mein/ordner/bericht" + ]; + + test.each(validUrls)("url %s is recognized as valid", (url) => { + const validWebsite = Website.from({ value: url }); + expect(validWebsite.value.toString()).toBe(url); }); - test("returns an error when trying to create an Attribute value type Website with a domain which begins with a - because this is not allowed for domains.", function () { +}); + +describe("Test invalid URLs", () => { + const invalidUrls = ["google-.de", "www.google", "www.-google", "https://inwind.test it"]; + + test.each(invalidUrls)("url %s is recognized as invalid", (url) => { const invalidWebsiteCall = () => { Website.from({ - value: "-google.de" + value: url }); }; expect(invalidWebsiteCall).toThrow( new ParsingError( "Website", "value", - "Value does not match regular expression /^(?:|[A-Za-z]{3,9}:(?:[/][/])?|[:](?:[/][/])?|(?:[/][/]))(?:(www[.])(?:[A-Za-z0-9\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df](?:[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9-]{0,61}[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9]){0,1}[.])|((?!www[.])(?:[A-Za-z0-9\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df](?:[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9-]{0,61}[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9]){0,1}[.])))[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9](?:[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9-]{0,61}[A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9])(?:[:][0-9]+){0,}(?:[/][A-Za-z\\u00c4\\u00e4\\u00d6\\u00f6\\u00dc\\u00fc\\u00df0-9?#@!$&'()*+/,;=%-]{0,}){0,}$/" + "Value does not match regular expression /^([A-Za-z]{3,9}[:]([/][/])?|[:]([/][/])?|([/][/]))?((www[.])([A-Za-z0-9ÄäÖöÜüß]([A-Za-zÄäÖöÜüß0-9-]{0,61}[A-Za-zÄäÖöÜüß0-9])?[.])+|((?!www[.])([A-Za-z0-9ÄäÖöÜüß]([A-Za-zÄäÖöÜüß0-9-]{0,61}[A-Za-zÄäÖöÜüß0-9])?[.]))([A-Za-z0-9ÄäÖöÜüß]([A-Za-zÄäÖöÜüß0-9-]{0,61}[A-Za-zÄäÖöÜüß0-9])?[.])*)[A-Za-zÄäÖöÜüß0-9]([A-Za-zÄäÖöÜüß0-9-]{0,61}[A-Za-zÄäÖöÜüß0-9])([:][0-9]+)*([/][A-Za-zÄäÖöÜüß0-9?#@!$&'()*+,;=%-]*)*$/" ) ); }); From e045ae1bc8aea4c88e11a4ee33f3f598cf868eff Mon Sep 17 00:00:00 2001 From: Ruth Di Giacomo Date: Wed, 5 Jun 2024 10:40:55 +0200 Subject: [PATCH 13/19] chore: version bump --- package-lock.json | 6 +++--- packages/content/package.json | 2 +- packages/runtime/package.json | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/package-lock.json b/package-lock.json index 8f8394180..75d393a7d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -12305,7 +12305,7 @@ }, "packages/content": { "name": "@nmshd/content", - "version": "2.10.1", + "version": "2.10.2", "license": "MIT", "dependencies": { "@js-soft/logging-abstractions": "^1.0.1", @@ -12330,7 +12330,7 @@ }, "packages/runtime": { "name": "@nmshd/runtime", - "version": "4.10.6", + "version": "4.10.7", "license": "MIT", "dependencies": { "@js-soft/docdb-querytranslator": "^1.1.4", @@ -12338,7 +12338,7 @@ "@js-soft/ts-serval": "2.0.10", "@js-soft/ts-utils": "^2.3.3", "@nmshd/consumption": "3.11.0", - "@nmshd/content": "2.10.1", + "@nmshd/content": "2.10.2", "@nmshd/crypto": "2.0.6", "@nmshd/transport": "2.7.5", "ajv": "^8.13.0", diff --git a/packages/content/package.json b/packages/content/package.json index f908cd341..ec0d535d1 100644 --- a/packages/content/package.json +++ b/packages/content/package.json @@ -1,6 +1,6 @@ { "name": "@nmshd/content", - "version": "2.10.1", + "version": "2.10.2", "description": "The content library defines data structures that can be transmitted using the transport library.", "homepage": "https://enmeshed.eu", "repository": { diff --git a/packages/runtime/package.json b/packages/runtime/package.json index f506ea832..010d82657 100644 --- a/packages/runtime/package.json +++ b/packages/runtime/package.json @@ -1,6 +1,6 @@ { "name": "@nmshd/runtime", - "version": "4.10.6", + "version": "4.10.7", "description": "The enmeshed client runtime.", "homepage": "https://enmeshed.eu", "repository": { @@ -57,7 +57,7 @@ "@js-soft/ts-serval": "2.0.10", "@js-soft/ts-utils": "^2.3.3", "@nmshd/consumption": "3.11.0", - "@nmshd/content": "2.10.1", + "@nmshd/content": "2.10.2", "@nmshd/crypto": "2.0.6", "@nmshd/transport": "2.7.5", "ajv": "^8.13.0", From 2c2b4ed083638cba23298151ea5a7961700d4bf2 Mon Sep 17 00:00:00 2001 From: Ruth Di Giacomo Date: Wed, 5 Jun 2024 12:23:06 +0200 Subject: [PATCH 14/19] feat: make regexp more readable --- .../attributes/types/strings/AbstractEMailAddress.ts | 8 ++++---- .../src/attributes/types/strings/AbstractURL.ts | 11 ++++++----- packages/content/test/attributes/EMailAddress.test.ts | 2 +- packages/content/test/attributes/Website.test.ts | 3 +-- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/packages/content/src/attributes/types/strings/AbstractEMailAddress.ts b/packages/content/src/attributes/types/strings/AbstractEMailAddress.ts index 89b71021b..8c855ea84 100644 --- a/packages/content/src/attributes/types/strings/AbstractEMailAddress.ts +++ b/packages/content/src/attributes/types/strings/AbstractEMailAddress.ts @@ -4,14 +4,14 @@ import { AbstractString } from "../AbstractString"; export abstract class AbstractEMailAddress extends AbstractString { // from https://html.spec.whatwg.org/multipage/input.html#valid-e-mail-address - + private static regExp = new RegExp( + /^[A-Za-z0-9!#$%&'*+/=?^_`{|}~-]+(\.[A-Za-z0-9!#$%&'*+/=?^_`{|}~-]+)*@([A-Za-z0-9ÄäÖöÜüß]([A-Za-z0-9ÄäÖöÜüß-]{0,61}[A-Za-z0-9ÄäÖöÜüß])?\.)+[A-Za-z0-9ÄäÖöÜüß][A-Za-z0-9ÄäÖöÜüß-]{0,61}[A-Za-z0-9ÄäÖöÜüß]$/ + ); @serialize() @validate({ min: 3, max: 254, - regExp: new RegExp( - /^[A-Za-z0-9!#$%&'*+/=?^_`{|}~-]+(?:[.][A-Za-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[A-Za-z0-9ÄäÖöÜüß](?:[A-Za-z0-9ÄäÖöÜüß-]{0,61}[A-Za-z0-9ÄäÖöÜüß])?[.])+[A-Za-z0-9ÄäÖöÜüß](?:[A-Za-z0-9ÄäÖöÜüß-]{0,61}[A-Za-z0-9ÄäÖöÜüß])$/ - ) + regExp: AbstractEMailAddress.regExp }) public override value: string; diff --git a/packages/content/src/attributes/types/strings/AbstractURL.ts b/packages/content/src/attributes/types/strings/AbstractURL.ts index 92fc03553..ebd45c625 100644 --- a/packages/content/src/attributes/types/strings/AbstractURL.ts +++ b/packages/content/src/attributes/types/strings/AbstractURL.ts @@ -3,13 +3,15 @@ import { RenderHints, RenderHintsDataType, RenderHintsEditType, ValueHints } fro import { AbstractString } from "../AbstractString"; export abstract class AbstractURL extends AbstractString { + private static regExp = new RegExp( + /^([A-Za-z]+:\/\/)?(www\.([A-Za-z0-9ÄäÖöÜüß]([A-Za-zÄäÖöÜüß0-9-]{0,61}[A-Za-zÄäÖöÜüß0-9])?\.)+|((?!www[.])([A-Za-z0-9ÄäÖöÜüß]([A-Za-zÄäÖöÜüß0-9-]{0,61}[A-Za-zÄäÖöÜüß0-9])?[.]))([A-Za-z0-9ÄäÖöÜüß]([A-Za-zÄäÖöÜüß0-9-]{0,61}[A-Za-zÄäÖöÜüß0-9])?\.)*)[A-Za-zÄäÖöÜüß0-9]([A-Za-zÄäÖöÜüß0-9-]{0,61}[A-Za-zÄäÖöÜüß0-9])([:][0-9]+)*(\/[A-Za-zÄäÖöÜüß0-9?#@!$&'()*+,;=%-]*)*$/ + ); + @serialize() @validate({ min: 3, max: 1024, - regExp: new RegExp( - /^([A-Za-z]{3,9}[:]([/][/])?|[:]([/][/])?|([/][/]))?((www[.])([A-Za-z0-9ÄäÖöÜüß]([A-Za-zÄäÖöÜüß0-9-]{0,61}[A-Za-zÄäÖöÜüß0-9])?[.])+|((?!www[.])([A-Za-z0-9ÄäÖöÜüß]([A-Za-zÄäÖöÜüß0-9-]{0,61}[A-Za-zÄäÖöÜüß0-9])?[.]))([A-Za-z0-9ÄäÖöÜüß]([A-Za-zÄäÖöÜüß0-9-]{0,61}[A-Za-zÄäÖöÜüß0-9])?[.])*)[A-Za-zÄäÖöÜüß0-9]([A-Za-zÄäÖöÜüß0-9-]{0,61}[A-Za-zÄäÖöÜüß0-9])([:][0-9]+)*([/][A-Za-zÄäÖöÜüß0-9?#@!$&'()*+,;=%-]*)*$/ - ) + regExp: AbstractURL.regExp }) public override value: string; @@ -17,8 +19,7 @@ export abstract class AbstractURL extends AbstractString { return super.valueHints.copyWith({ min: 3, max: 1024, - pattern: - "/^([A-Za-z]{3,9}[:]([/][/])?|[:]([/][/])?|([/][/]))?((www[.])([A-Za-z0-9ÄäÖöÜüß]([A-Za-zÄäÖöÜüß0-9-]{0,61}[A-Za-zÄäÖöÜüß0-9])?[.])+|((?!www[.])([A-Za-z0-9ÄäÖöÜüß]([A-Za-zÄäÖöÜüß0-9-]{0,61}[A-Za-zÄäÖöÜüß0-9])?[.]))([A-Za-z0-9ÄäÖöÜüß]([A-Za-zÄäÖöÜüß0-9-]{0,61}[A-Za-zÄäÖöÜüß0-9])?[.])*)[A-Za-zÄäÖöÜüß0-9]([A-Za-zÄäÖöÜüß0-9-]{0,61}[A-Za-zÄäÖöÜüß0-9])([:][0-9]+)*([/][A-Za-zÄäÖöÜüß0-9?#@!$&'()*+,;=%-]*)*$/" + pattern: JSON.stringify(AbstractURL.regExp, null, 2) }); } diff --git a/packages/content/test/attributes/EMailAddress.test.ts b/packages/content/test/attributes/EMailAddress.test.ts index 2454a1855..f26a77e02 100644 --- a/packages/content/test/attributes/EMailAddress.test.ts +++ b/packages/content/test/attributes/EMailAddress.test.ts @@ -23,7 +23,7 @@ describe("Test invalid EMailAdresses", () => { new ParsingError( "EMailAddress", "value", - "Value does not match regular expression /^[A-Za-z0-9!#$%&'*+/=?^_`{|}~-]+(?:[.][A-Za-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[A-Za-z0-9ÄäÖöÜüß](?:[A-Za-z0-9ÄäÖöÜüß-]{0,61}[A-Za-z0-9ÄäÖöÜüß])?[.])+[A-Za-z0-9ÄäÖöÜüß](?:[A-Za-z0-9ÄäÖöÜüß-]{0,61}[A-Za-z0-9ÄäÖöÜüß])$/" + "Value does not match regular expression /^[A-Za-z0-9!#$%&'*+/=?^_`{|}~-]+(\\.[A-Za-z0-9!#$%&'*+/=?^_`{|}~-]+)*@([A-Za-z0-9ÄäÖöÜüß]([A-Za-z0-9ÄäÖöÜüß-]{0,61}[A-Za-z0-9ÄäÖöÜüß])?\\.)+[A-Za-z0-9ÄäÖöÜüß][A-Za-z0-9ÄäÖöÜüß-]{0,61}[A-Za-z0-9ÄäÖöÜüß]$/" ) ); }); diff --git a/packages/content/test/attributes/Website.test.ts b/packages/content/test/attributes/Website.test.ts index 131057236..4fd4492e5 100644 --- a/packages/content/test/attributes/Website.test.ts +++ b/packages/content/test/attributes/Website.test.ts @@ -6,7 +6,6 @@ describe("Test valid URLs", () => { "www.google.com", "https://döner.cooking", "http://inwind.it", - "//google.it", "https://enmeshed.de/blog/meilenstein-enmeshed-als-komponente-ablage-in-mein-bildungsraum-geht-in-die-testphase-der-beta-version/", "www.foo.www.www.enmeshed.eu", "https://example.org:8080/mein/ordner/bericht" @@ -31,7 +30,7 @@ describe("Test invalid URLs", () => { new ParsingError( "Website", "value", - "Value does not match regular expression /^([A-Za-z]{3,9}[:]([/][/])?|[:]([/][/])?|([/][/]))?((www[.])([A-Za-z0-9ÄäÖöÜüß]([A-Za-zÄäÖöÜüß0-9-]{0,61}[A-Za-zÄäÖöÜüß0-9])?[.])+|((?!www[.])([A-Za-z0-9ÄäÖöÜüß]([A-Za-zÄäÖöÜüß0-9-]{0,61}[A-Za-zÄäÖöÜüß0-9])?[.]))([A-Za-z0-9ÄäÖöÜüß]([A-Za-zÄäÖöÜüß0-9-]{0,61}[A-Za-zÄäÖöÜüß0-9])?[.])*)[A-Za-zÄäÖöÜüß0-9]([A-Za-zÄäÖöÜüß0-9-]{0,61}[A-Za-zÄäÖöÜüß0-9])([:][0-9]+)*([/][A-Za-zÄäÖöÜüß0-9?#@!$&'()*+,;=%-]*)*$/" + "Value does not match regular expression /^([A-Za-z]+:\\/\\/)?(www\\.([A-Za-z0-9ÄäÖöÜüß]([A-Za-zÄäÖöÜüß0-9-]{0,61}[A-Za-zÄäÖöÜüß0-9])?\\.)+|((?!www[.])([A-Za-z0-9ÄäÖöÜüß]([A-Za-zÄäÖöÜüß0-9-]{0,61}[A-Za-zÄäÖöÜüß0-9])?[.]))([A-Za-z0-9ÄäÖöÜüß]([A-Za-zÄäÖöÜüß0-9-]{0,61}[A-Za-zÄäÖöÜüß0-9])?\\.)*)[A-Za-zÄäÖöÜüß0-9]([A-Za-zÄäÖöÜüß0-9-]{0,61}[A-Za-zÄäÖöÜüß0-9])([:][0-9]+)*(\\/[A-Za-zÄäÖöÜüß0-9?#@!$&'()*+,;=%-]*)*$/" ) ); }); From 825bbee80d406047d8c8551235c138e2341b370e Mon Sep 17 00:00:00 2001 From: Ruth Di Giacomo Date: Wed, 5 Jun 2024 12:29:11 +0200 Subject: [PATCH 15/19] fix: changed an error --- .../src/attributes/types/strings/AbstractEMailAddress.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/content/src/attributes/types/strings/AbstractEMailAddress.ts b/packages/content/src/attributes/types/strings/AbstractEMailAddress.ts index 8c855ea84..1777e997e 100644 --- a/packages/content/src/attributes/types/strings/AbstractEMailAddress.ts +++ b/packages/content/src/attributes/types/strings/AbstractEMailAddress.ts @@ -19,7 +19,7 @@ export abstract class AbstractEMailAddress extends AbstractString { return super.valueHints.copyWith({ min: 3, max: 254, - pattern: String(RegExp) + pattern: JSON.stringify(AbstractEMailAddress.regExp, null, 2) }); } From f1b4fdfbd78d43d242a2aa427c1b1bd69e3284c8 Mon Sep 17 00:00:00 2001 From: Ruth Di Giacomo Date: Thu, 6 Jun 2024 12:29:56 +0200 Subject: [PATCH 16/19] fix: error and last changes --- .../src/attributes/types/strings/AbstractEMailAddress.ts | 2 +- .../content/src/attributes/types/strings/AbstractURL.ts | 2 +- packages/content/test/attributes/EMailAddress.test.ts | 4 ++-- packages/content/test/attributes/Website.test.ts | 6 +++--- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/packages/content/src/attributes/types/strings/AbstractEMailAddress.ts b/packages/content/src/attributes/types/strings/AbstractEMailAddress.ts index 1777e997e..10f6cd108 100644 --- a/packages/content/src/attributes/types/strings/AbstractEMailAddress.ts +++ b/packages/content/src/attributes/types/strings/AbstractEMailAddress.ts @@ -4,7 +4,7 @@ import { AbstractString } from "../AbstractString"; export abstract class AbstractEMailAddress extends AbstractString { // from https://html.spec.whatwg.org/multipage/input.html#valid-e-mail-address - private static regExp = new RegExp( + private static readonly regExp = new RegExp( /^[A-Za-z0-9!#$%&'*+/=?^_`{|}~-]+(\.[A-Za-z0-9!#$%&'*+/=?^_`{|}~-]+)*@([A-Za-z0-9ÄäÖöÜüß]([A-Za-z0-9ÄäÖöÜüß-]{0,61}[A-Za-z0-9ÄäÖöÜüß])?\.)+[A-Za-z0-9ÄäÖöÜüß][A-Za-z0-9ÄäÖöÜüß-]{0,61}[A-Za-z0-9ÄäÖöÜüß]$/ ); @serialize() diff --git a/packages/content/src/attributes/types/strings/AbstractURL.ts b/packages/content/src/attributes/types/strings/AbstractURL.ts index ebd45c625..917b2d2e5 100644 --- a/packages/content/src/attributes/types/strings/AbstractURL.ts +++ b/packages/content/src/attributes/types/strings/AbstractURL.ts @@ -3,7 +3,7 @@ import { RenderHints, RenderHintsDataType, RenderHintsEditType, ValueHints } fro import { AbstractString } from "../AbstractString"; export abstract class AbstractURL extends AbstractString { - private static regExp = new RegExp( + private static readonly regExp = new RegExp( /^([A-Za-z]+:\/\/)?(www\.([A-Za-z0-9ÄäÖöÜüß]([A-Za-zÄäÖöÜüß0-9-]{0,61}[A-Za-zÄäÖöÜüß0-9])?\.)+|((?!www[.])([A-Za-z0-9ÄäÖöÜüß]([A-Za-zÄäÖöÜüß0-9-]{0,61}[A-Za-zÄäÖöÜüß0-9])?[.]))([A-Za-z0-9ÄäÖöÜüß]([A-Za-zÄäÖöÜüß0-9-]{0,61}[A-Za-zÄäÖöÜüß0-9])?\.)*)[A-Za-zÄäÖöÜüß0-9]([A-Za-zÄäÖöÜüß0-9-]{0,61}[A-Za-zÄäÖöÜüß0-9])([:][0-9]+)*(\/[A-Za-zÄäÖöÜüß0-9?#@!$&'()*+,;=%-]*)*$/ ); diff --git a/packages/content/test/attributes/EMailAddress.test.ts b/packages/content/test/attributes/EMailAddress.test.ts index f26a77e02..2e6c00019 100644 --- a/packages/content/test/attributes/EMailAddress.test.ts +++ b/packages/content/test/attributes/EMailAddress.test.ts @@ -1,7 +1,7 @@ import { ParsingError } from "@js-soft/ts-serval"; import { EMailAddress } from "../../src"; -describe("Test valid EMailAdresses", () => { +describe("Test valid EMailAddresses", () => { const validEMailAddresses = ["peter123@inwind.it", "peter123@inwänd.it"]; test.each(validEMailAddresses)("EMail %s is recognized as valid", (email) => { @@ -10,7 +10,7 @@ describe("Test valid EMailAdresses", () => { }); }); -describe("Test invalid EMailAdresses", () => { +describe("Test invalid EMailAddresses", () => { const invalidEMailAddresses = ["Hugo Becker@gmx.de", "Becker@gmx", "Becker@gmx-.de", "Becker@gmx-.de", ".Becker@gmx.de", "test@.address", "test@test..address"]; test.each(invalidEMailAddresses)("EMail %s is recognized as invalid", (email) => { diff --git a/packages/content/test/attributes/Website.test.ts b/packages/content/test/attributes/Website.test.ts index 4fd4492e5..e0521371b 100644 --- a/packages/content/test/attributes/Website.test.ts +++ b/packages/content/test/attributes/Website.test.ts @@ -4,14 +4,14 @@ import { Website } from "../../src"; describe("Test valid URLs", () => { const validUrls = [ "www.google.com", - "https://döner.cooking", + "https://inwänd.it", "http://inwind.it", "https://enmeshed.de/blog/meilenstein-enmeshed-als-komponente-ablage-in-mein-bildungsraum-geht-in-die-testphase-der-beta-version/", "www.foo.www.www.enmeshed.eu", "https://example.org:8080/mein/ordner/bericht" ]; - test.each(validUrls)("url %s is recognized as valid", (url) => { + test.each(validUrls)("URL %s is recognized as valid", (url) => { const validWebsite = Website.from({ value: url }); expect(validWebsite.value.toString()).toBe(url); }); @@ -20,7 +20,7 @@ describe("Test valid URLs", () => { describe("Test invalid URLs", () => { const invalidUrls = ["google-.de", "www.google", "www.-google", "https://inwind.test it"]; - test.each(invalidUrls)("url %s is recognized as invalid", (url) => { + test.each(invalidUrls)("URL %s is recognized as invalid", (url) => { const invalidWebsiteCall = () => { Website.from({ value: url From b324923afebf619d8d2dfe5f8532039730bf7b22 Mon Sep 17 00:00:00 2001 From: Ruth Di Giacomo Date: Fri, 7 Jun 2024 10:18:24 +0200 Subject: [PATCH 17/19] feat: last changes --- .../attributes/types/strings/AbstractEMailAddress.ts | 2 +- .../src/attributes/types/strings/AbstractURL.ts | 4 ++-- packages/content/test/attributes/EMailAddress.test.ts | 8 ++++++++ packages/content/test/attributes/Website.test.ts | 10 +++++++++- 4 files changed, 20 insertions(+), 4 deletions(-) diff --git a/packages/content/src/attributes/types/strings/AbstractEMailAddress.ts b/packages/content/src/attributes/types/strings/AbstractEMailAddress.ts index 10f6cd108..db1858576 100644 --- a/packages/content/src/attributes/types/strings/AbstractEMailAddress.ts +++ b/packages/content/src/attributes/types/strings/AbstractEMailAddress.ts @@ -19,7 +19,7 @@ export abstract class AbstractEMailAddress extends AbstractString { return super.valueHints.copyWith({ min: 3, max: 254, - pattern: JSON.stringify(AbstractEMailAddress.regExp, null, 2) + pattern: String(AbstractEMailAddress.regExp) }); } diff --git a/packages/content/src/attributes/types/strings/AbstractURL.ts b/packages/content/src/attributes/types/strings/AbstractURL.ts index 917b2d2e5..5b7619fe7 100644 --- a/packages/content/src/attributes/types/strings/AbstractURL.ts +++ b/packages/content/src/attributes/types/strings/AbstractURL.ts @@ -4,7 +4,7 @@ import { AbstractString } from "../AbstractString"; export abstract class AbstractURL extends AbstractString { private static readonly regExp = new RegExp( - /^([A-Za-z]+:\/\/)?(www\.([A-Za-z0-9ÄäÖöÜüß]([A-Za-zÄäÖöÜüß0-9-]{0,61}[A-Za-zÄäÖöÜüß0-9])?\.)+|((?!www[.])([A-Za-z0-9ÄäÖöÜüß]([A-Za-zÄäÖöÜüß0-9-]{0,61}[A-Za-zÄäÖöÜüß0-9])?[.]))([A-Za-z0-9ÄäÖöÜüß]([A-Za-zÄäÖöÜüß0-9-]{0,61}[A-Za-zÄäÖöÜüß0-9])?\.)*)[A-Za-zÄäÖöÜüß0-9]([A-Za-zÄäÖöÜüß0-9-]{0,61}[A-Za-zÄäÖöÜüß0-9])([:][0-9]+)*(\/[A-Za-zÄäÖöÜüß0-9?#@!$&'()*+,;=%-]*)*$/ + /^([A-Za-z]+:\/\/)?((www\.)|(?!www\.))([A-Za-z0-9ÄäÖöÜüß]([A-Za-zÄäÖöÜüß0-9-]{0,61}[A-Za-zÄäÖöÜüß0-9])?\.)+([A-Za-z0-9ÄäÖöÜüß]([A-Za-zÄäÖöÜüß0-9-]{0,61}[A-Za-zÄäÖöÜüß0-9])?)(:[0-9]+)?(\/[A-Za-zÄäÖöÜüß0-9?#@!$&'()*+,;=%-]*)*$/ ); @serialize() @@ -19,7 +19,7 @@ export abstract class AbstractURL extends AbstractString { return super.valueHints.copyWith({ min: 3, max: 1024, - pattern: JSON.stringify(AbstractURL.regExp, null, 2) + pattern: String(AbstractURL.regExp) }); } diff --git a/packages/content/test/attributes/EMailAddress.test.ts b/packages/content/test/attributes/EMailAddress.test.ts index 2e6c00019..ddf22e0bf 100644 --- a/packages/content/test/attributes/EMailAddress.test.ts +++ b/packages/content/test/attributes/EMailAddress.test.ts @@ -27,4 +27,12 @@ describe("Test invalid EMailAddresses", () => { ) ); }); + test("returns an error when trying to create an Attribute Value Type EMailAddress wich is empty", function () { + const invalidEMailAddressCall = () => { + EMailAddress.from({ + value: "" + }); + }; + expect(invalidEMailAddressCall).toThrow(new ParsingError("EMailAddress", "value", "Value is shorter than 3 characters")); + }); }); diff --git a/packages/content/test/attributes/Website.test.ts b/packages/content/test/attributes/Website.test.ts index e0521371b..53fba0c46 100644 --- a/packages/content/test/attributes/Website.test.ts +++ b/packages/content/test/attributes/Website.test.ts @@ -30,8 +30,16 @@ describe("Test invalid URLs", () => { new ParsingError( "Website", "value", - "Value does not match regular expression /^([A-Za-z]+:\\/\\/)?(www\\.([A-Za-z0-9ÄäÖöÜüß]([A-Za-zÄäÖöÜüß0-9-]{0,61}[A-Za-zÄäÖöÜüß0-9])?\\.)+|((?!www[.])([A-Za-z0-9ÄäÖöÜüß]([A-Za-zÄäÖöÜüß0-9-]{0,61}[A-Za-zÄäÖöÜüß0-9])?[.]))([A-Za-z0-9ÄäÖöÜüß]([A-Za-zÄäÖöÜüß0-9-]{0,61}[A-Za-zÄäÖöÜüß0-9])?\\.)*)[A-Za-zÄäÖöÜüß0-9]([A-Za-zÄäÖöÜüß0-9-]{0,61}[A-Za-zÄäÖöÜüß0-9])([:][0-9]+)*(\\/[A-Za-zÄäÖöÜüß0-9?#@!$&'()*+,;=%-]*)*$/" + "Value does not match regular expression /^([A-Za-z]+:\\/\\/)?((www\\.)|(?!www\\.))([A-Za-z0-9ÄäÖöÜüß]([A-Za-zÄäÖöÜüß0-9-]{0,61}[A-Za-zÄäÖöÜüß0-9])?\\.)+([A-Za-z0-9ÄäÖöÜüß]([A-Za-zÄäÖöÜüß0-9-]{0,61}[A-Za-zÄäÖöÜüß0-9])?)(:[0-9]+)?(\\/[A-Za-zÄäÖöÜüß0-9?#@!$&'()*+,;=%-]*)*$/" ) ); }); + test("returns an error when trying to create an Attribute Value Type Website wich is empty", function () { + const invalidWebsiteCall = () => { + Website.from({ + value: "" + }); + }; + expect(invalidWebsiteCall).toThrow(new ParsingError("Website", "value", "Value is shorter than 3 characters")); + }); }); From 677088fc697c7e764248ac798a8ddea5bb8aa1db Mon Sep 17 00:00:00 2001 From: Ruth Di Giacomo Date: Fri, 7 Jun 2024 10:23:52 +0200 Subject: [PATCH 18/19] chore: version bump --- packages/content/package-lock.json | 180 +++++++++++++++++++++++++++++ 1 file changed, 180 insertions(+) create mode 100644 packages/content/package-lock.json diff --git a/packages/content/package-lock.json b/packages/content/package-lock.json new file mode 100644 index 000000000..68f722171 --- /dev/null +++ b/packages/content/package-lock.json @@ -0,0 +1,180 @@ +{ + "name": "@nmshd/content", + "version": "2.10.2", + "lockfileVersion": 2, + "requires": true, + "packages": { + "": { + "name": "@nmshd/content", + "version": "2.10.2", + "license": "MIT", + "dependencies": { + "@js-soft/logging-abstractions": "^1.0.1", + "@nmshd/iql": "^1.0.2", + "ts-simple-nameof": "^1.3.1" + }, + "devDependencies": { + "@js-soft/ts-serval": "2.0.10", + "@nmshd/crypto": "2.0.6", + "@types/luxon": "^3.4.2" + } + }, + "node_modules/@js-soft/logging-abstractions": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/@js-soft/logging-abstractions/-/logging-abstractions-1.0.1.tgz", + "integrity": "sha512-giFnUcpfq07vNmMFetvI1bfKo8g5slIiQbSnwLF1dHU8gLE/hJmL3jTnchXFRTwSeMhTFCNg0GudsNMw1esMVQ==" + }, + "node_modules/@js-soft/ts-serval": { + "version": "2.0.10", + "resolved": "https://registry.npmjs.org/@js-soft/ts-serval/-/ts-serval-2.0.10.tgz", + "integrity": "sha512-TMeVmDaHs1zk5JPXR6LBY1EXwukHCB7MgBgMbxf/bbauDNMw54t9nH+gE7xXFxBTovL4RWIw5NSIHk7n3T+wYg==", + "dev": true, + "dependencies": { + "lodash": "^4.17.21", + "reflect-metadata": "^0.1.13" + } + }, + "node_modules/@nmshd/crypto": { + "version": "2.0.6", + "resolved": "https://registry.npmjs.org/@nmshd/crypto/-/crypto-2.0.6.tgz", + "integrity": "sha512-6A0vZcpd6a28vWkF3Ph7fiVgGHw1GB88cYUcaaqeMNTebRpb+jIkT+7KiU/qI74/qrWz0pf4fiNTrXWXz1NnXg==", + "dev": true, + "dependencies": { + "libsodium-wrappers-sumo": "0.7.13", + "uuid": "9.0.1" + } + }, + "node_modules/@nmshd/iql": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/@nmshd/iql/-/iql-1.0.2.tgz", + "integrity": "sha512-fRUIDoZeAKDJ99/yjbjlKryMv1poNaiRDTC8eNltZJSPSkQgchlt0yrWHBDl+CZEPF2Ae0hDj7vpo2n0c6R6JA==" + }, + "node_modules/@types/luxon": { + "version": "3.4.2", + "resolved": "https://registry.npmjs.org/@types/luxon/-/luxon-3.4.2.tgz", + "integrity": "sha512-TifLZlFudklWlMBfhubvgqTXRzLDI5pCbGa4P8a3wPyUQSW+1xQ5eDsreP9DWHX3tjq1ke96uYG/nwundroWcA==", + "dev": true + }, + "node_modules/libsodium-sumo": { + "version": "0.7.13", + "resolved": "https://registry.npmjs.org/libsodium-sumo/-/libsodium-sumo-0.7.13.tgz", + "integrity": "sha512-zTGdLu4b9zSNLfovImpBCbdAA4xkpkZbMnSQjP8HShyOutnGjRHmSOKlsylh1okao6QhLiz7nG98EGn+04cZjQ==", + "dev": true + }, + "node_modules/libsodium-wrappers-sumo": { + "version": "0.7.13", + "resolved": "https://registry.npmjs.org/libsodium-wrappers-sumo/-/libsodium-wrappers-sumo-0.7.13.tgz", + "integrity": "sha512-lz4YdplzDRh6AhnLGF2Dj2IUj94xRN6Bh8T0HLNwzYGwPehQJX6c7iYVrFUPZ3QqxE0bqC+K0IIqqZJYWumwSQ==", + "dev": true, + "dependencies": { + "libsodium-sumo": "^0.7.13" + } + }, + "node_modules/lodash": { + "version": "4.17.21", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz", + "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==", + "dev": true + }, + "node_modules/reflect-metadata": { + "version": "0.1.14", + "resolved": "https://registry.npmjs.org/reflect-metadata/-/reflect-metadata-0.1.14.tgz", + "integrity": "sha512-ZhYeb6nRaXCfhnndflDK8qI6ZQ/YcWZCISRAWICW9XYqMUwjZM9Z0DveWX/ABN01oxSHwVxKQmxeYZSsm0jh5A==", + "dev": true + }, + "node_modules/ts-simple-nameof": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/ts-simple-nameof/-/ts-simple-nameof-1.3.1.tgz", + "integrity": "sha512-E0xwaLwDmKmSmo4DE4i+Rp0CuixeZ6wJcn4+2OugzSoPxWW27aNRHhfhcfAELavHHS077dt998oXIMFq+MqeBw==" + }, + "node_modules/uuid": { + "version": "9.0.1", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-9.0.1.tgz", + "integrity": "sha512-b+1eJOlsR9K8HJpow9Ok3fiWOWSIcIzXodvv0rQjVoOVNpWMpxf1wZNpt4y9h10odCNrqnYp1OBzRktckBe3sA==", + "dev": true, + "funding": [ + "https://github.com/sponsors/broofa", + "https://github.com/sponsors/ctavan" + ], + "bin": { + "uuid": "dist/bin/uuid" + } + } + }, + "dependencies": { + "@js-soft/logging-abstractions": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/@js-soft/logging-abstractions/-/logging-abstractions-1.0.1.tgz", + "integrity": "sha512-giFnUcpfq07vNmMFetvI1bfKo8g5slIiQbSnwLF1dHU8gLE/hJmL3jTnchXFRTwSeMhTFCNg0GudsNMw1esMVQ==" + }, + "@js-soft/ts-serval": { + "version": "2.0.10", + "resolved": "https://registry.npmjs.org/@js-soft/ts-serval/-/ts-serval-2.0.10.tgz", + "integrity": "sha512-TMeVmDaHs1zk5JPXR6LBY1EXwukHCB7MgBgMbxf/bbauDNMw54t9nH+gE7xXFxBTovL4RWIw5NSIHk7n3T+wYg==", + "dev": true, + "requires": { + "lodash": "^4.17.21", + "reflect-metadata": "^0.1.13" + } + }, + "@nmshd/crypto": { + "version": "2.0.6", + "resolved": "https://registry.npmjs.org/@nmshd/crypto/-/crypto-2.0.6.tgz", + "integrity": "sha512-6A0vZcpd6a28vWkF3Ph7fiVgGHw1GB88cYUcaaqeMNTebRpb+jIkT+7KiU/qI74/qrWz0pf4fiNTrXWXz1NnXg==", + "dev": true, + "requires": { + "libsodium-wrappers-sumo": "0.7.13", + "uuid": "9.0.1" + } + }, + "@nmshd/iql": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/@nmshd/iql/-/iql-1.0.2.tgz", + "integrity": "sha512-fRUIDoZeAKDJ99/yjbjlKryMv1poNaiRDTC8eNltZJSPSkQgchlt0yrWHBDl+CZEPF2Ae0hDj7vpo2n0c6R6JA==" + }, + "@types/luxon": { + "version": "3.4.2", + "resolved": "https://registry.npmjs.org/@types/luxon/-/luxon-3.4.2.tgz", + "integrity": "sha512-TifLZlFudklWlMBfhubvgqTXRzLDI5pCbGa4P8a3wPyUQSW+1xQ5eDsreP9DWHX3tjq1ke96uYG/nwundroWcA==", + "dev": true + }, + "libsodium-sumo": { + "version": "0.7.13", + "resolved": "https://registry.npmjs.org/libsodium-sumo/-/libsodium-sumo-0.7.13.tgz", + "integrity": "sha512-zTGdLu4b9zSNLfovImpBCbdAA4xkpkZbMnSQjP8HShyOutnGjRHmSOKlsylh1okao6QhLiz7nG98EGn+04cZjQ==", + "dev": true + }, + "libsodium-wrappers-sumo": { + "version": "0.7.13", + "resolved": "https://registry.npmjs.org/libsodium-wrappers-sumo/-/libsodium-wrappers-sumo-0.7.13.tgz", + "integrity": "sha512-lz4YdplzDRh6AhnLGF2Dj2IUj94xRN6Bh8T0HLNwzYGwPehQJX6c7iYVrFUPZ3QqxE0bqC+K0IIqqZJYWumwSQ==", + "dev": true, + "requires": { + "libsodium-sumo": "^0.7.13" + } + }, + "lodash": { + "version": "4.17.21", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz", + "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==", + "dev": true + }, + "reflect-metadata": { + "version": "0.1.14", + "resolved": "https://registry.npmjs.org/reflect-metadata/-/reflect-metadata-0.1.14.tgz", + "integrity": "sha512-ZhYeb6nRaXCfhnndflDK8qI6ZQ/YcWZCISRAWICW9XYqMUwjZM9Z0DveWX/ABN01oxSHwVxKQmxeYZSsm0jh5A==", + "dev": true + }, + "ts-simple-nameof": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/ts-simple-nameof/-/ts-simple-nameof-1.3.1.tgz", + "integrity": "sha512-E0xwaLwDmKmSmo4DE4i+Rp0CuixeZ6wJcn4+2OugzSoPxWW27aNRHhfhcfAELavHHS077dt998oXIMFq+MqeBw==" + }, + "uuid": { + "version": "9.0.1", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-9.0.1.tgz", + "integrity": "sha512-b+1eJOlsR9K8HJpow9Ok3fiWOWSIcIzXodvv0rQjVoOVNpWMpxf1wZNpt4y9h10odCNrqnYp1OBzRktckBe3sA==", + "dev": true + } + } +} From 0ce518a4b1a3f8d5fc219797ca023f9efb1959f4 Mon Sep 17 00:00:00 2001 From: Ruth Di Giacomo Date: Fri, 7 Jun 2024 10:33:02 +0200 Subject: [PATCH 19/19] fix: delete unnecessary file --- packages/content/package-lock.json | 180 ----------------------------- 1 file changed, 180 deletions(-) delete mode 100644 packages/content/package-lock.json diff --git a/packages/content/package-lock.json b/packages/content/package-lock.json deleted file mode 100644 index 68f722171..000000000 --- a/packages/content/package-lock.json +++ /dev/null @@ -1,180 +0,0 @@ -{ - "name": "@nmshd/content", - "version": "2.10.2", - "lockfileVersion": 2, - "requires": true, - "packages": { - "": { - "name": "@nmshd/content", - "version": "2.10.2", - "license": "MIT", - "dependencies": { - "@js-soft/logging-abstractions": "^1.0.1", - "@nmshd/iql": "^1.0.2", - "ts-simple-nameof": "^1.3.1" - }, - "devDependencies": { - "@js-soft/ts-serval": "2.0.10", - "@nmshd/crypto": "2.0.6", - "@types/luxon": "^3.4.2" - } - }, - "node_modules/@js-soft/logging-abstractions": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/@js-soft/logging-abstractions/-/logging-abstractions-1.0.1.tgz", - "integrity": "sha512-giFnUcpfq07vNmMFetvI1bfKo8g5slIiQbSnwLF1dHU8gLE/hJmL3jTnchXFRTwSeMhTFCNg0GudsNMw1esMVQ==" - }, - "node_modules/@js-soft/ts-serval": { - "version": "2.0.10", - "resolved": "https://registry.npmjs.org/@js-soft/ts-serval/-/ts-serval-2.0.10.tgz", - "integrity": "sha512-TMeVmDaHs1zk5JPXR6LBY1EXwukHCB7MgBgMbxf/bbauDNMw54t9nH+gE7xXFxBTovL4RWIw5NSIHk7n3T+wYg==", - "dev": true, - "dependencies": { - "lodash": "^4.17.21", - "reflect-metadata": "^0.1.13" - } - }, - "node_modules/@nmshd/crypto": { - "version": "2.0.6", - "resolved": "https://registry.npmjs.org/@nmshd/crypto/-/crypto-2.0.6.tgz", - "integrity": "sha512-6A0vZcpd6a28vWkF3Ph7fiVgGHw1GB88cYUcaaqeMNTebRpb+jIkT+7KiU/qI74/qrWz0pf4fiNTrXWXz1NnXg==", - "dev": true, - "dependencies": { - "libsodium-wrappers-sumo": "0.7.13", - "uuid": "9.0.1" - } - }, - "node_modules/@nmshd/iql": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/@nmshd/iql/-/iql-1.0.2.tgz", - "integrity": "sha512-fRUIDoZeAKDJ99/yjbjlKryMv1poNaiRDTC8eNltZJSPSkQgchlt0yrWHBDl+CZEPF2Ae0hDj7vpo2n0c6R6JA==" - }, - "node_modules/@types/luxon": { - "version": "3.4.2", - "resolved": "https://registry.npmjs.org/@types/luxon/-/luxon-3.4.2.tgz", - "integrity": "sha512-TifLZlFudklWlMBfhubvgqTXRzLDI5pCbGa4P8a3wPyUQSW+1xQ5eDsreP9DWHX3tjq1ke96uYG/nwundroWcA==", - "dev": true - }, - "node_modules/libsodium-sumo": { - "version": "0.7.13", - "resolved": "https://registry.npmjs.org/libsodium-sumo/-/libsodium-sumo-0.7.13.tgz", - "integrity": "sha512-zTGdLu4b9zSNLfovImpBCbdAA4xkpkZbMnSQjP8HShyOutnGjRHmSOKlsylh1okao6QhLiz7nG98EGn+04cZjQ==", - "dev": true - }, - "node_modules/libsodium-wrappers-sumo": { - "version": "0.7.13", - "resolved": "https://registry.npmjs.org/libsodium-wrappers-sumo/-/libsodium-wrappers-sumo-0.7.13.tgz", - "integrity": "sha512-lz4YdplzDRh6AhnLGF2Dj2IUj94xRN6Bh8T0HLNwzYGwPehQJX6c7iYVrFUPZ3QqxE0bqC+K0IIqqZJYWumwSQ==", - "dev": true, - "dependencies": { - "libsodium-sumo": "^0.7.13" - } - }, - "node_modules/lodash": { - "version": "4.17.21", - "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz", - "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==", - "dev": true - }, - "node_modules/reflect-metadata": { - "version": "0.1.14", - "resolved": "https://registry.npmjs.org/reflect-metadata/-/reflect-metadata-0.1.14.tgz", - "integrity": "sha512-ZhYeb6nRaXCfhnndflDK8qI6ZQ/YcWZCISRAWICW9XYqMUwjZM9Z0DveWX/ABN01oxSHwVxKQmxeYZSsm0jh5A==", - "dev": true - }, - "node_modules/ts-simple-nameof": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/ts-simple-nameof/-/ts-simple-nameof-1.3.1.tgz", - "integrity": "sha512-E0xwaLwDmKmSmo4DE4i+Rp0CuixeZ6wJcn4+2OugzSoPxWW27aNRHhfhcfAELavHHS077dt998oXIMFq+MqeBw==" - }, - "node_modules/uuid": { - "version": "9.0.1", - "resolved": "https://registry.npmjs.org/uuid/-/uuid-9.0.1.tgz", - "integrity": "sha512-b+1eJOlsR9K8HJpow9Ok3fiWOWSIcIzXodvv0rQjVoOVNpWMpxf1wZNpt4y9h10odCNrqnYp1OBzRktckBe3sA==", - "dev": true, - "funding": [ - "https://github.com/sponsors/broofa", - "https://github.com/sponsors/ctavan" - ], - "bin": { - "uuid": "dist/bin/uuid" - } - } - }, - "dependencies": { - "@js-soft/logging-abstractions": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/@js-soft/logging-abstractions/-/logging-abstractions-1.0.1.tgz", - "integrity": "sha512-giFnUcpfq07vNmMFetvI1bfKo8g5slIiQbSnwLF1dHU8gLE/hJmL3jTnchXFRTwSeMhTFCNg0GudsNMw1esMVQ==" - }, - "@js-soft/ts-serval": { - "version": "2.0.10", - "resolved": "https://registry.npmjs.org/@js-soft/ts-serval/-/ts-serval-2.0.10.tgz", - "integrity": "sha512-TMeVmDaHs1zk5JPXR6LBY1EXwukHCB7MgBgMbxf/bbauDNMw54t9nH+gE7xXFxBTovL4RWIw5NSIHk7n3T+wYg==", - "dev": true, - "requires": { - "lodash": "^4.17.21", - "reflect-metadata": "^0.1.13" - } - }, - "@nmshd/crypto": { - "version": "2.0.6", - "resolved": "https://registry.npmjs.org/@nmshd/crypto/-/crypto-2.0.6.tgz", - "integrity": "sha512-6A0vZcpd6a28vWkF3Ph7fiVgGHw1GB88cYUcaaqeMNTebRpb+jIkT+7KiU/qI74/qrWz0pf4fiNTrXWXz1NnXg==", - "dev": true, - "requires": { - "libsodium-wrappers-sumo": "0.7.13", - "uuid": "9.0.1" - } - }, - "@nmshd/iql": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/@nmshd/iql/-/iql-1.0.2.tgz", - "integrity": "sha512-fRUIDoZeAKDJ99/yjbjlKryMv1poNaiRDTC8eNltZJSPSkQgchlt0yrWHBDl+CZEPF2Ae0hDj7vpo2n0c6R6JA==" - }, - "@types/luxon": { - "version": "3.4.2", - "resolved": "https://registry.npmjs.org/@types/luxon/-/luxon-3.4.2.tgz", - "integrity": "sha512-TifLZlFudklWlMBfhubvgqTXRzLDI5pCbGa4P8a3wPyUQSW+1xQ5eDsreP9DWHX3tjq1ke96uYG/nwundroWcA==", - "dev": true - }, - "libsodium-sumo": { - "version": "0.7.13", - "resolved": "https://registry.npmjs.org/libsodium-sumo/-/libsodium-sumo-0.7.13.tgz", - "integrity": "sha512-zTGdLu4b9zSNLfovImpBCbdAA4xkpkZbMnSQjP8HShyOutnGjRHmSOKlsylh1okao6QhLiz7nG98EGn+04cZjQ==", - "dev": true - }, - "libsodium-wrappers-sumo": { - "version": "0.7.13", - "resolved": "https://registry.npmjs.org/libsodium-wrappers-sumo/-/libsodium-wrappers-sumo-0.7.13.tgz", - "integrity": "sha512-lz4YdplzDRh6AhnLGF2Dj2IUj94xRN6Bh8T0HLNwzYGwPehQJX6c7iYVrFUPZ3QqxE0bqC+K0IIqqZJYWumwSQ==", - "dev": true, - "requires": { - "libsodium-sumo": "^0.7.13" - } - }, - "lodash": { - "version": "4.17.21", - "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz", - "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==", - "dev": true - }, - "reflect-metadata": { - "version": "0.1.14", - "resolved": "https://registry.npmjs.org/reflect-metadata/-/reflect-metadata-0.1.14.tgz", - "integrity": "sha512-ZhYeb6nRaXCfhnndflDK8qI6ZQ/YcWZCISRAWICW9XYqMUwjZM9Z0DveWX/ABN01oxSHwVxKQmxeYZSsm0jh5A==", - "dev": true - }, - "ts-simple-nameof": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/ts-simple-nameof/-/ts-simple-nameof-1.3.1.tgz", - "integrity": "sha512-E0xwaLwDmKmSmo4DE4i+Rp0CuixeZ6wJcn4+2OugzSoPxWW27aNRHhfhcfAELavHHS077dt998oXIMFq+MqeBw==" - }, - "uuid": { - "version": "9.0.1", - "resolved": "https://registry.npmjs.org/uuid/-/uuid-9.0.1.tgz", - "integrity": "sha512-b+1eJOlsR9K8HJpow9Ok3fiWOWSIcIzXodvv0rQjVoOVNpWMpxf1wZNpt4y9h10odCNrqnYp1OBzRktckBe3sA==", - "dev": true - } - } -}