From d5af0f5def598d5fde015a7f808dc24f28fa48ef Mon Sep 17 00:00:00 2001 From: "R. S. Doiel" Date: Wed, 11 Dec 2024 17:21:16 -0800 Subject: [PATCH] commiting to main --- email.ts | 11 +++++++++++ email_test.ts | 20 ++++++++++++++++++++ mdt.js | 2 +- mtd.1.md | 4 ++-- version.ts | 2 +- 5 files changed, 35 insertions(+), 4 deletions(-) create mode 100644 email.ts create mode 100644 email_test.ts diff --git a/email.ts b/email.ts new file mode 100644 index 0000000..6463372 --- /dev/null +++ b/email.ts @@ -0,0 +1,11 @@ +export const EMAILPattern = '^(?:"?([^"]*)"?\\s)?(?:]+)>?)$'; +export const reEMAIL = new RegExp(EMAILPattern); + +export function normalizeEMAIL(email: string): string { + return email.trim().replaceAll(/\s+/g,'').trim(); +} + +export function validateEMAIL(email: string): boolean { + const normalized = normalizeEMAIL(email); + return reEMAIL.test(normalized); +} \ No newline at end of file diff --git a/email_test.ts b/email_test.ts new file mode 100644 index 0000000..df6de4e --- /dev/null +++ b/email_test.ts @@ -0,0 +1,20 @@ +import { assertEquals } from "@std/assert"; + +import { normalizeEMAIL, validateEMAIL } from './email.ts'; + +const varified_ids: string[] = [ + "a@localhost", + "a.b@localhost", + "b_2@example.edu", + "b3@library.example.edu", + "b4@agents.library.example.edu", +]; + +for (let id of varified_ids) { + // Normalize + let normalized = normalizeEMAIL(id); + console.log(`Normalized Email: ${normalized}`); + // Validate + assertEquals(validateEMAIL(id), true); +} + \ No newline at end of file diff --git a/mdt.js b/mdt.js index 90ddeba..3cda3aa 100644 --- a/mdt.js +++ b/mdt.js @@ -2,7 +2,7 @@ const appInfo = { appName: "metadatatools", version: "0.0.4", releaseDate: "2024-12-11", - releaseHash: "135b003", + releaseHash: "c2f1637", licenseText: ` Copyright (c) 2024, Caltech All rights not granted herein are expressly reserved by Caltech. diff --git a/mtd.1.md b/mtd.1.md index b35ff99..18ad59f 100644 --- a/mtd.1.md +++ b/mtd.1.md @@ -1,6 +1,6 @@ -%mtd(1) user manual | 0.0.4 2024-12-11 135b003 +%mtd(1) user manual | 0.0.4 2024-12-11 c2f1637 % R. S.Doiel -% 2024-12-11 135b003 +% 2024-12-11 c2f1637 # NAME diff --git a/version.ts b/version.ts index 828ae5a..32905d9 100644 --- a/version.ts +++ b/version.ts @@ -12,7 +12,7 @@ export const appInfo: {[k: string]: string} = { releaseDate: "2024-12-11", // ReleaseHash, the Git hash when version.go was generated - releaseHash: "135b003", + releaseHash: "c2f1637", // licenseText holds a copy of the application license text. licenseText: `