Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
DISCONTINUED! use https://github.com/snd/url-pattern directly
CoffeeScript
branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
.gitignore polish
.travis.yml fix node version it .travis.yml
LICENSE initial commit
README.md Update README.md
index.coffee polish
package.json bump version to 0.2.0
test.coffee polish

README.md

url-whitelist (DISCONTINUED!)

Build Status

url-whitelist can create whitelists by including and excluding url patterns and check urls against them

see url-pattern for supported url patterns

install

npm install url-whitelist

use

require
newWhitelist = require 'url-whitelist'
make a new whitelist
whitelist = newWhitelist()
whitelist a url pattern
whitelist.include '/users/:id'
check whether urls are on the whitelist
whitelist.check '/users/1' # => true
whitelist.check '/projects/1' # => false
blacklisting

by default a whitelist excludes everything. you can include everything by default and then selectively exclude patterns.

blacklist = newWhitelist()
blacklist.include '*'

blacklist.exclude '/users/:id'

blacklist.check 'sajdflkasjdfl' # => true
blacklist.check '/users/:id' # => false
blacklist.check 'skljdf' # => true

example

whitelist /projects/* except for /projects/hidden/* and projects/:id/secret. also whitelist /users/:id

newWhitelist = require 'url-whitelist'

whitelist = newWhitelist()

whitelist.include '/projects/*'
whitelist.exclude '/projects/hidden/*'
whitelist.exclude '/projects/:id/secret'
whitelist.include '/users/:id'

whitelist.check '/projects/foo/bar/baz' # => true
whitelist.check '/projects/hidden/bar/baz' # => false
whitelist.check '/projects/5/secret' # => false
whitelist.check '/projects/5/secret/foo' # => true

whitelist.check '/users' # => false
whitelist.check '/users/5' # => true

whitelist.check '/tasks/57' # => false

how check works (pseudocode)

whitelisted = false
go through all include- and exclude-patterns in the order they were defined:
    if url matches pattern
        if is include
            whitelisted = true
        else
            whitelisted = false

license: MIT

Something went wrong with that request. Please try again.