Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/firstandthird/redirect-whitelister
Checks if a url contains a valid domain from a whitelist
https://github.com/firstandthird/redirect-whitelister
Last synced: 14 days ago
JSON representation
Checks if a url contains a valid domain from a whitelist
- Host: GitHub
- URL: https://github.com/firstandthird/redirect-whitelister
- Owner: firstandthird
- Created: 2018-02-04T18:06:12.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2018-02-04T18:42:34.000Z (almost 7 years ago)
- Last Synced: 2024-08-10T23:25:01.120Z (6 months ago)
- Language: JavaScript
- Size: 1.95 KB
- Stars: 1
- Watchers: 4
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
## redirect-whitelister
```shell
npm install redirect-whitelister
```Usage:
```js
const RedirectWhitelister = require('redirect-whitelister');
const whitelister = new RedirectWhitelister();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:
```javascript
const RedirectWhitelister = require('redirect-whitelister');
const whitelister = new RedirectWhitelister();whitelister.allowedProtocols = ['gopher:', 'http:', 'https:'];
```#### Validating a url
- `verify()` - Returns a boolean if the url contains a domain that matches any of the allowed domains.