Functional Weave
Code in TypeScript

auth.normalise-email@1.0.0

vectors.json

1,370 bytes · view raw

[
  { "name": "surrounding spaces are trimmed and the domain lower-cased; the local part keeps its case", "args": ["  Alice@Example.COM  "], "expect": "Alice@example.com" },
  { "name": "an address already in stored form is unchanged", "args": ["alice@example.com"], "expect": "alice@example.com" },
  { "name": "a tab and a trailing newline from a paste", "args": ["\tbob@EXAMPLE.org\n"], "expect": "bob@example.org" },
  { "name": "dots and a +tag in the local part are kept, not folded", "args": ["Alice.Smith+News@Mail.Example.CO.UK"], "expect": "Alice.Smith+News@mail.example.co.uk" },
  { "name": "the shortest address accepted", "args": ["a@B.CO"], "expect": "a@b.co" },
  { "name": "the empty string is not an address", "args": [""], "expect": null },
  { "name": "only whitespace is not an address", "args": ["   "], "expect": null },
  { "name": "text with no at sign", "args": ["not an email"], "expect": null },
  { "name": "a space inside the address is not trimmed away", "args": ["alice @example.com"], "expect": null },
  { "name": "a bare host name is not deliverable from outside", "args": [" alice@localhost "], "expect": null },
  { "name": "a trailing no-break space is not ASCII whitespace, so the address is refused", "args": ["alice@example.com "], "expect": null },
  { "name": "two at signs", "args": ["alice@example@com"], "expect": null }
]