is-allowed

Am I allowed to redirect

Usage no npm install needed!

<script type="module">
  import isAllowed from 'https://cdn.skypack.dev/is-allowed';
</script>

README

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