PHP 8.2.30
Preview: emailPipe.js Size: 1.36 KB
/home/byroehnu/easepay.easetack.com/node_modules/text-mask-addons/src/emailPipe.js

const atSymbol = '@'
const allAtSymbolsRegExp = /@/g
const emptyString = ''
const atDot = '@.'
const dot = '.'
const dotDot = '..'
const emptyArray = []
const allDotsRegExp = /\./g

export default function emailPipe(conformedValue, config) {
  const {currentCaretPosition, rawValue, previousConformedValue, placeholderChar} = config

  let value = conformedValue

  value = removeAllAtSymbolsButFirst(value)

  const indexOfAtDot = value.indexOf(atDot)

  const emptyEmail = rawValue.match(new RegExp(`[^@\\s.${placeholderChar}]`)) === null

  if (emptyEmail) {
    return emptyString
  }

  if (
    value.indexOf(dotDot) !== -1 ||
    indexOfAtDot !== -1 && currentCaretPosition !== (indexOfAtDot + 1) ||
    rawValue.indexOf(atSymbol) === -1 && previousConformedValue !== emptyString && rawValue.indexOf(dot) !== -1
  ) {
    return false
  }

  const indexOfAtSymbol = value.indexOf(atSymbol)
  const domainPart = value.slice(indexOfAtSymbol + 1, value.length)

  if (
    (domainPart.match(allDotsRegExp) || emptyArray).length > 1 &&
    value.substr(-1) === dot &&
    currentCaretPosition !== rawValue.length
  ) {
    value = value.slice(0, value.length - 1)
  }

  return value
}

function removeAllAtSymbolsButFirst(str) {
  let atSymbolCount = 0

  return str.replace(allAtSymbolsRegExp, () => {
    atSymbolCount++

    return (atSymbolCount === 1) ? atSymbol : emptyString
  })
}

Directory Contents

Dirs: 0 × Files: 6

Name Size Perms Modified Actions
127 B lr--r--r-- 2026-03-14 01:49:21
Edit Download
2.17 KB lrw-r--r-- 2026-02-28 00:28:20
Edit Download
4.23 KB lrw-r--r-- 2026-02-28 00:28:24
Edit Download
3.46 KB lrw-r--r-- 2026-02-28 00:28:26
Edit Download
1.36 KB lrw-r--r-- 2026-02-28 00:28:28
Edit Download
197 B lrw-r--r-- 2026-02-28 00:28:28
Edit Download

If ZipArchive is unavailable, a .tar will be created (no compression).