cafe-utility 22.2.0 → 22.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/index.js +10 -3
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -746,10 +746,10 @@ function getBasename(n) {
746
746
  }
747
747
  function normalizeEmail(n) {
748
748
  let [t, e] = n.split('@')
749
- t = t.replaceAll('.', '').toLowerCase()
749
+ t = shrinkTrim(t.replaceAll('.', '').toLowerCase()).replaceAll(' ', '')
750
750
  const [r] = t.split('+')
751
751
  if (!r || !e || e.indexOf('.') === -1 || e.indexOf('.') === e.length - 1) throw new Error('Invalid email')
752
- return `${r}@${e.toLowerCase()}`
752
+ return (e = shrinkTrim(e.toLowerCase()).replaceAll(' ', '')), `${r}@${e}`
753
753
  }
754
754
  function normalizeFilename(n) {
755
755
  const t = getBasename(n),
@@ -779,7 +779,14 @@ function expand(n) {
779
779
  return u
780
780
  }
781
781
  function shrinkTrim(n) {
782
- return n.replace(/\s+/g, ' ').replace(/\s$|^\s/g, '')
782
+ return n
783
+ .split(
784
+ `
785
+ `
786
+ )
787
+ .map(t => t.trim().replace(/\s+/g, ' '))
788
+ .filter(t => t.length > 0).join(`
789
+ `)
783
790
  }
784
791
  function capitalize(n) {
785
792
  return n.charAt(0).toUpperCase() + n.slice(1)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cafe-utility",
3
- "version": "22.2.0",
3
+ "version": "22.2.1",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "exports": {