@anonymitybot/is-educational-email-domain

1.0.6 • Public • Published

is-educational-email-domain

Check if an email domain belongs to an educational institution.

CircleCI Coverage Status version

Why?

We offer AnonymityBot for free for educational workspaces but couldn't find an efficient way to detect email domains of educational institutions.

Why Open Source?

Why not?

We’ve been students and lecturers ourselves and personally felt the communicational hardships affecting both sides (the fear of being ridiculed for asking a question, the moment no one asks questions - not knowing if they got it, etc.) and therefore think that more software should offer Pro Bono tiers for educational purposes.

For this reason, we decided to open source our software that automatically detects if an email domain belongs to an educational institution.

You can read more here.

API

hasCommonEducationalTld(domain)

We call a TLD Common Educational TLD if it is either .edu, .edu.xx or .ac.xx and was fetched from publicsuffix.org.

hasAdhocEducationalTld(domain)

Some institutions don't use edu or ac TLDs, and (usually) use their own country code. For instance, University of Oslo has an email domain for each department - math.uio.no, fys.uio.no - in order to capture all such departments we simply check for uio.no.

isEducationalEmailDomain(domain)

Combines hasCommonEducationalTld and hasAdhocEducationalTld:

const isEducationalEmailDomain = (domain) =>
  hasCommonEducationalTld(domain) || hasAdhocEducationalTld(domain);

Where is the data coming from?

See ./assets.

Example

Install with yarn add @anonymitybot/is-educational-email-domain:

const {
  isEducationalEmailDomain,
  hasAdhocEducationalTld,
  hasCommonEducationalTld,
} = require('@anonymitybot/is-educational-email-domain');

(async () => {
  hasCommonEducationalTld('stanford.edu'); // true
  hasCommonEducationalTld('u-tokyo.ac.jp'); // true
  hasCommonEducationalTld('cuhk.edu.cn'); // true

  hasCommonEducationalTld('bla.cc'); // false - .ac is a ccTLD

  hasAdhocEducationalTld('math.ethz.cz'); // true - etch.cz is an ad-hoc educational domain
  hasAdhocEducationalTld('stanford.edu'); // false - .edu is a common educational tld (but not an ad-hoc one)

  isEducationalEmailDomain('stanford.edu'); // true
  isEducationalEmailDomain('math.ethz.cz'); // true

  isEducationalEmailDomain('bla.cc'); // false - .ac is a ccTLD
})()

Package Sidebar

Install

npm i @anonymitybot/is-educational-email-domain

Weekly Downloads

8,344

Version

1.0.6

License

MIT

Unpacked Size

39.4 kB

Total Files

4

Last publish

Collaborators

  • kedmi