Skip to content

Commit

Permalink
commiting to main
Browse files Browse the repository at this point in the history
  • Loading branch information
R. S. Doiel committed Dec 12, 2024
1 parent c2f1637 commit d5af0f5
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 4 deletions.
11 changes: 11 additions & 0 deletions email.ts
Original file line number Diff line number Diff line change
@@ -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);
}
20 changes: 20 additions & 0 deletions email_test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { assertEquals } from "@std/assert";

import { normalizeEMAIL, validateEMAIL } from './email.ts';

const varified_ids: string[] = [
"a@localhost",
"a.b@localhost",
"[email protected]",
"[email protected]",
"[email protected]",
];

for (let id of varified_ids) {
// Normalize
let normalized = normalizeEMAIL(id);
console.log(`Normalized Email: ${normalized}`);
// Validate
assertEquals(validateEMAIL(id), true);
}

2 changes: 1 addition & 1 deletion mdt.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
4 changes: 2 additions & 2 deletions mtd.1.md
Original file line number Diff line number Diff line change
@@ -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

Expand Down
2 changes: 1 addition & 1 deletion version.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: `
Expand Down

0 comments on commit d5af0f5

Please sign in to comment.