extract-email-address
Advanced tools
Comparing version 1.4.0 to 3.0.1
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.default = void 0; | ||
var _tlds = _interopRequireDefault(require("tlds")); | ||
var _normalizeInput = _interopRequireDefault(require("./normalizeInput")); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
var _default = input => { | ||
const matches = (0, _normalizeInput.default)(input).match(/(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))/g); | ||
if (!matches) { | ||
return []; | ||
} | ||
return matches.map(email => { | ||
return email; | ||
}).filter(email => { | ||
for (const tld of _tlds.default) { | ||
if (email.endsWith('.' + tld)) { | ||
return true; | ||
} | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.extractEmail = void 0; | ||
const normalizeInput_1 = require("./normalizeInput"); | ||
const tlds_1 = __importDefault(require("tlds")); | ||
const extractEmail = (input) => { | ||
const matches = (0, normalizeInput_1.normalizeInput)(input).match( | ||
// eslint-disable-next-line unicorn/better-regex, require-unicode-regexp, regexp/no-unused-capturing-group | ||
/(([^\s"(),.:;<>@[\\\]]+(\.[^\s"(),.:;<>@[\\\]]+)*)|(".+"))@((\[(?:\d{1,3}\.){3}\d{1,3}\])|(([\dA-Za-z\-]+\.)+[A-Za-z]{2,}))/g); | ||
if (!matches) { | ||
return []; | ||
} | ||
return false; | ||
}).filter((email, index, self) => { | ||
return self.indexOf(email) === index; | ||
}).map(email => { | ||
return { | ||
}; | ||
}); | ||
return matches | ||
.map((email) => { | ||
return email; | ||
}) | ||
.filter((email) => { | ||
for (const tld of tlds_1.default) { | ||
if (email.endsWith('.' + tld)) { | ||
return true; | ||
} | ||
} | ||
return false; | ||
}) | ||
.filter((email, index, self) => { | ||
return self.indexOf(email) === index; | ||
}) | ||
.map((email) => { | ||
return { | ||
email, | ||
}; | ||
}); | ||
}; | ||
exports.default = _default; | ||
exports.extractEmail = extractEmail; | ||
//# sourceMappingURL=extractEmail.js.map |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
Object.defineProperty(exports, "default", { | ||
enumerable: true, | ||
get: function () { | ||
return _extractEmail.default; | ||
} | ||
}); | ||
var _extractEmail = _interopRequireDefault(require("./extractEmail")); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.extractEmail = void 0; | ||
var extractEmail_1 = require("./extractEmail"); | ||
Object.defineProperty(exports, "extractEmail", { enumerable: true, get: function () { return extractEmail_1.extractEmail; } }); | ||
//# sourceMappingURL=index.js.map |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.default = void 0; | ||
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(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, '.') // Matches all ASCII characters from the space to tilde. | ||
.replace(/[^ -~]/g, ' ').trim().toLowerCase(); | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
exports.default = _default; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.normalizeInput = void 0; | ||
const emoji_regex_1 = __importDefault(require("emoji-regex")); | ||
const emojiRegex = (0, emoji_regex_1.default)(); | ||
const normalizeInput = (input) => { | ||
return (decodeURIComponent(input) | ||
.replace(emojiRegex, ' ') | ||
.replaceAll(/(?<=\s|^)([.\-_a-z])\s?(?=[.\-_a-z](?:\s|$))/gu, '$1') | ||
.replaceAll(/\s+at\s+/gu, '@') | ||
.replaceAll(/\s+dot\s+/gu, '.') | ||
.replaceAll(/\s*<at>\s*/gu, '@') | ||
.replaceAll(/\s*<dot>\s*/gu, '.') | ||
.replaceAll(/\s*\(at\)\s*/gu, '@') | ||
.replaceAll(/\s*\(dot\)\s*/gu, '.') | ||
.replaceAll(/\s*\[at\]\s*/gu, '@') | ||
.replaceAll(/\s*\[dot\]\s*/gu, '.') | ||
// Matches all ASCII characters from the space to tilde. | ||
// eslint-disable-next-line regexp/no-obscure-range | ||
.replaceAll(/[^ -~]/gu, ' ') | ||
.trim() | ||
.toLowerCase()); | ||
}; | ||
exports.normalizeInput = normalizeInput; | ||
//# sourceMappingURL=normalizeInput.js.map |
@@ -8,12 +8,10 @@ { | ||
"ava": { | ||
"babel": { | ||
"compileAsTests": [ | ||
"test/helpers/**/*" | ||
] | ||
}, | ||
"extensions": [ | ||
"ts" | ||
], | ||
"files": [ | ||
"test/extract-email-address/**/*" | ||
"src/**/*.test.ts" | ||
], | ||
"require": [ | ||
"@babel/register" | ||
"ts-node/register/transpile-only" | ||
] | ||
@@ -23,25 +21,13 @@ }, | ||
"emoji-regex": "^9.0.0", | ||
"tlds": "^1.207.0" | ||
"tlds": "^1.253.0" | ||
}, | ||
"description": "Extracts email address from an arbitrary text input.", | ||
"devDependencies": { | ||
"@ava/babel": "^1.0.0", | ||
"@babel/cli": "^7.8.4", | ||
"@babel/core": "^7.8.4", | ||
"@babel/node": "^7.8.4", | ||
"@babel/plugin-transform-flow-strip-types": "^7.8.3", | ||
"@babel/preset-env": "^7.8.4", | ||
"@babel/register": "^7.8.3", | ||
"ava": "^3.1.0", | ||
"babel-plugin-istanbul": "^6.0.0", | ||
"coveralls": "^3.0.9", | ||
"eslint": "^6.8.0", | ||
"eslint-config-canonical": "^18.1.0", | ||
"flow-bin": "^0.117.0", | ||
"flow-copy-source": "^2.0.9", | ||
"gitdown": "^3.1.2", | ||
"husky": "^4.2.1", | ||
"nyc": "^15.0.0", | ||
"semantic-release": "^17.0.2", | ||
"sinon": "^8.1.1" | ||
"ava": "^6.1.3", | ||
"del-cli": "^5.1.0", | ||
"eslint": "^8.57.0", | ||
"eslint-config-canonical": "^43.0.13", | ||
"semantic-release": "^24.0.0", | ||
"sinon": "^18.0.0", | ||
"ts-node": "^10.9.2" | ||
}, | ||
@@ -51,8 +37,2 @@ "engines": { | ||
}, | ||
"husky": { | ||
"hooks": { | ||
"pre-commit": "npm run lint && npm run test && npm run build", | ||
"pre-push": "gitdown ./.README/README.md --output-file ./README.md --check" | ||
} | ||
}, | ||
"keywords": [ | ||
@@ -67,15 +47,2 @@ "date", | ||
"name": "extract-email-address", | ||
"nyc": { | ||
"include": [ | ||
"src/**/*.js" | ||
], | ||
"instrument": false, | ||
"reporter": [ | ||
"text-lcov" | ||
], | ||
"require": [ | ||
"@babel/register" | ||
], | ||
"sourceMap": false | ||
}, | ||
"repository": { | ||
@@ -86,8 +53,7 @@ "type": "git", | ||
"scripts": { | ||
"build": "rm -fr ./dist && NODE_ENV=production babel ./src --out-dir ./dist --copy-files --source-maps && flow-copy-source src dist", | ||
"create-readme": "gitdown ./.README/README.md --output-file ./README.md", | ||
"build": "del-cli ./dist && tsc", | ||
"lint": "eslint ./src ./test && flow", | ||
"test": "NODE_ENV=test ava --verbose --serial" | ||
}, | ||
"version": "1.4.0" | ||
"version": "3.0.1" | ||
} |
@@ -23,9 +23,8 @@ <a name="extract-email-address"></a> | ||
```js | ||
import extractEmail from 'extract-email-address'; | ||
import type { | ||
EmailMatchType, | ||
import { | ||
extractEmail, | ||
type EmailMatch, | ||
} from 'extract-email-address'; | ||
extractEmail(input: string): $ReadOnlyArray<EmailMatchType>; | ||
extractEmail(input: string): readonly EmailMatch[]; | ||
``` | ||
@@ -37,3 +36,3 @@ | ||
```js | ||
import extractEmail from 'extract-email-address'; | ||
import { extractEmail } from 'extract-email-address'; | ||
@@ -40,0 +39,0 @@ extractEmail('extracts email from anywhere within the input gajus@gajus.com'); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
23469
7
30
341
76
1
Updatedtlds@^1.253.0