Skip to content

Commit

Permalink
remove all runtime Javascript dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
matthieusieben committed Nov 24, 2024
1 parent b64bedf commit 169e332
Show file tree
Hide file tree
Showing 4 changed files with 87 additions and 76 deletions.
87 changes: 52 additions & 35 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 4 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -147,17 +147,15 @@
},
"author": "Francois-Guillaume Ribreau <[email protected]> (http://fgribreau.com)",
"license": "MIT",
"dependencies": {
"dependencies": {},
"devDependencies": {
"async": "^3.1.0",
"eventemitter2": "^6.0.0",
"github-changes": "^2.0.3",
"glob": "^7.0.3",
"lodash": "^4.17.15",
"mu2": "~0.5.20",
"node-range": "0.1.x"
},
"devDependencies": {
"github-changes": "^2.0.3",
"mocha": "^7.0.0",
"mu2": "~0.5.20",
"nodeunit": "^0.11.3",
"npm-release": "^1.0.0",
"npm-run-all": "^4.1.5",
Expand Down
38 changes: 18 additions & 20 deletions platform/node/index.js

Large diffs are not rendered by default.

28 changes: 13 additions & 15 deletions platform/node/index.tmpl.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,26 +7,24 @@
*/
'use strict';

var range = require('node-range');

var blacklist = new Set([{{& listSTR }}]);
var isValidEmail = /^{{& unanchoredRegexpString }}$/;

function allDomainSuffixes(email) {
var domainComponents = email.split('@')[1].split('.');

return range(0, domainComponents.length).map(function (n) {
return domainComponents.slice(n).join('.');
});
}

function isBlacklisted(email) {
function suffixIsBlacklisted(domainSuffix) {
return blacklist.has(domainSuffix);
}
var currentDomain = email.split("@")[1];
var nextDot;

return allDomainSuffixes(email).some(suffixIsBlacklisted);
};
do {
if (blacklist.has(currentDomain)) {
return true;
}
} while (
(nextDot = currentDomain.indexOf(".")) !== -1 &&
(currentDomain = currentDomain.slice(nextDot + 1))
);

return false;
}

module.exports = {
isValid: function (email){
Expand Down

0 comments on commit 169e332

Please sign in to comment.