npm.io
1.2.0 • Published 5 years ago

is-allowed

Licence
ISC
Version
1.2.0
Deps
0
Size
3 kB
Vulns
0
Weekly
0
Stars
3

Am I Allowed To Redirect

npm i is-allowed

Single domain & tld

const domain = "https://google.com";
const redirect = new Redirect(domain);
redirect.isAllowed("/") // true
redirect.isAllowed("/test") // true

Multiple domain & tld

const domain = "https://google.com";
const redirect = new Redirect(domain, ['com', 'de', 'fr', 'ru']);
redirect.isAllowed("/") // true
redirect.isAllowed("https://google.ru/test") // true

Also supports subdomains.

const domain = "https://google.com";
const redirect = new Redirect(domain, ['com', 'de', 'fr', 'ru']);
redirect.isAllowed("https://subdomain.google.ru/test") // true

Keywords