1.0.0 • Published 8 years ago

domain-match v1.0.0

Weekly downloads
232
License
MIT
Repository
-
Last release
8 years ago

domain-match

Check if a given url matches against simple domain name patterns.

NPM version Build Status Coverage Status

Installation

Install via npm

$ npm install domain-match

Description

Use this function to test a URL matches a domain name pattern.

The domain name patterns can optionally followed by path prefix.

wild cardMatching URLsNon-matching URLs
*http://abc.com/
http://abc.def.com
http://abc.com/path/file
wild card TLDsMatching URLsNon-matching URLs
*.domain.comhttp://domain.com/http://niamod.com/
http://sub.domain.com
http://domain.com/path/file
wild card subdomainsMatching URLsNon-matching URLs
*.sub.domain.comhttp://sub.domain.com/http://domain.com/
http://sub.sub.domain.com/http://bus.domain.com/
http://sub.domain.com/path/file
specific TLDsMatching URLsNon-matching URLs
domain.comhttp://domain.com/http://niamod.com/
http://domain.com/path/filehttp://sub.domain.com
specific subdomainsMatching URLsNon-matching URLs
sub.domain.comhttp://sub.domain.com/http://sub.niamod.com/
http://sub.domain.com/path/filehttp://abc.domain.com

Usage

var domainMatch = require('domain-match'); 
var matched = domainMatch('*.abc.com/prefix/path', 'http://www.abc.com/prefix/path/filename.ext');
// matched == true

License

MIT