@tadashi/whitelister

1.0.0 • Public • Published

whitelister

NPM version Build Status Coverage Status

npm install -S @tadashi/whitelister

Usage

import Whitelister from 'whitelister'

const whitelister = new Whitelister(<domain-list>)
const validUrl = whitelister.verify('https://example.com/test/1234?s=test')

Options

  • domain-list - Either an array or single string domain. Domains may contain wildcards eg: test.*.example.com. You can also use simple regex (see tests cases).

Overriding Protocols

By default only http and https are allowed. If you need to change this, say to support a custom protocol for a mobile app:

import Whitelister from 'whitelister'
const whitelister = new Whitelister(<domain-list>)

whitelister.allowedProtocols = ['gopher:', 'http:', 'https:']

Validating a url

  • verify(<url>) - Returns a boolean if the url contains a domain that matches any of the allowed domains.

Dependencies (0)

    Dev Dependencies (7)

    Package Sidebar

    Install

    npm i @tadashi/whitelister

    Weekly Downloads

    6

    Version

    1.0.0

    License

    MIT

    Unpacked Size

    3.38 kB

    Total Files

    3

    Last publish

    Collaborators

    • lagden