extract-email-address
Advanced tools
Comparing version 1.1.0 to 1.2.0
@@ -8,4 +8,10 @@ "use strict"; | ||
var _emojiRegex = _interopRequireDefault(require("emoji-regex")); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
const emojiRegex = (0, _emojiRegex.default)(); | ||
var _default = input => { | ||
return input.replace(/(?<=\s|^)([a-z0-9.-_@])\s?(?=[a-z0-9.-_@](?:\s|$))/g, '$1').replace(/\s+at\s+/g, '@').replace(/\s+dot\s+/g, '.').replace(/\s*<at>\s*/g, '@').replace(/\s*<dot>\s*/g, '.').replace(/\s*\(at\)\s*/g, '@').replace(/\s*\(dot\)\s*/g, '.').replace(/\s*\[at\]\s*/g, '@').replace(/\s*\[dot\]\s*/g, '.'); | ||
return input.replace(emojiRegex, ' ').replace(/(?<=\s|^)([a-z0-9.-_@])\s?(?=[a-z0-9.-_@](?:\s|$))/g, '$1').replace(/\s+at\s+/g, '@').replace(/\s+dot\s+/g, '.').replace(/\s*<at>\s*/g, '@').replace(/\s*<dot>\s*/g, '.').replace(/\s*\(at\)\s*/g, '@').replace(/\s*\(dot\)\s*/g, '.').replace(/\s*\[at\]\s*/g, '@').replace(/\s*\[dot\]\s*/g, '.').trim(); | ||
}; | ||
@@ -12,0 +18,0 @@ |
@@ -21,2 +21,3 @@ { | ||
"dependencies": { | ||
"emoji-regex": "^9.0.0", | ||
"tlds": "^1.207.0" | ||
@@ -87,3 +88,3 @@ }, | ||
}, | ||
"version": "1.1.0" | ||
"version": "1.2.0" | ||
} |
@@ -23,2 +23,3 @@ <a name="extract-email-address"></a> | ||
```js | ||
import extractEmail from 'extract-email-address'; | ||
import type { | ||
@@ -28,2 +29,4 @@ EmailMatchType, | ||
extractEmail(input: string): $ReadOnlyArray<EmailMatchType>; | ||
``` | ||
@@ -49,2 +52,5 @@ | ||
extractEmail('extracts emails surrounded by emojis, e.g. 📧gajus@gajus.com'); | ||
// [{email: 'gajus@gajus.com'}] | ||
extractEmail('excludes invalid emails with invalid TLDs, e.g. gajus@gajus.png'); | ||
@@ -51,0 +57,0 @@ // [] |
// @flow | ||
import createEmojiRegex from 'emoji-regex'; | ||
const emojiRegex = createEmojiRegex(); | ||
export default (input: string): string => { | ||
return input | ||
.replace(emojiRegex, ' ') | ||
.replace(/(?<=\s|^)([a-z0-9.-_@])\s?(?=[a-z0-9.-_@](?:\s|$))/g, '$1') | ||
@@ -13,3 +18,4 @@ .replace(/\s+at\s+/g, '@') | ||
.replace(/\s*\[at\]\s*/g, '@') | ||
.replace(/\s*\[dot\]\s*/g, '.'); | ||
.replace(/\s*\[dot\]\s*/g, '.') | ||
.trim(); | ||
}; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
15334
117
74
2
+ Addedemoji-regex@^9.0.0
+ Addedemoji-regex@9.2.2(transitive)