Match-url-wildcard ![Build Status](https://camo.githubusercontent.com/ae2631fafd690f68fd5b0fe65171f2f83d6d7684e50e6cd2c274d17e41973a02/68747470733a2f2f7472617669732d63692e6f72672f416c65784b616d6165762f6d617463682d75726c2d77696c64636172642e7376673f6272616e63683d6d6173746572)
Module to match url by pattern
expect(matchUrl('google.com.uk', rule)).to.be.false;
expect(matchUrl('docs.google.com', rule)).to.be.false;
expect(matchUrl('http://docs.google.com', rule)).to.be.false;
expect(matchUrl('https://docs.google.com', rule)).to.be.false;
expect(matchUrl('www.docs.google.com', rule)).to.be.false;
expect(matchUrl('http://docs.ggoogle.com', rule)).to.be.false;
expect(matchUrl('http://goooogle.com', rule)).to.be.false;
expect(matchUrl('gogoogle.com', rule)).to.be.false;
expect(matchUrl('http://google.com', rule)).to.be.true;
expect(matchUrl('https://google.com', rule)).to.be.true;
expect(matchUrl('https://google.com/', rule)).to.be.true;
expect(matchUrl('google.com/', rule)).to.be.true;
expect(matchUrl('https://google.com', rule)).to.be.false;
expect(matchUrl('https://google.com/', rule)).to.be.false;
expect(matchUrl('docs.google.com', rule)).to.be.false;
expect(matchUrl('http://docs.google.com', rule)).to.be.false;
expect(matchUrl('https://docs.google.com', rule)).to.be.false;
expect(matchUrl('www.docs.google.com', rule)).to.be.false;
expect(matchUrl('http://docs.ggoogle.com', rule)).to.be.false;
expect(matchUrl('http://google.com', rule)).to.be.true;
expect(matchUrl('google.com/', rule)).to.be.true;
expect(matchUrl('http://google.com', rule)).to.be.false;
expect(matchUrl('https://google.com', rule)).to.be.true;
['.google.com', '*.google.com']
.forEach(r => {
expect(matchUrl('http://google.com', r)).to.be.false;
expect(matchUrl('https://google.com', r)).to.be.false;
expect(matchUrl('https://google.com/', r)).to.be.false;
expect(matchUrl('google.com/', r)).to.be.false;
expect(matchUrl('http://docs.ggoogle.com', r)).to.be.false;
expect(matchUrl('docs.google.com', r)).to.be.true;
expect(matchUrl('http://docs.google.com', r)).to.be.true;
expect(matchUrl('https://docs.google.com', r)).to.be.true;
expect(matchUrl('www.docs.google.com', r)).to.be.true;
});
.forEach(r => {
expect(matchUrl('http://google.com.uk', r)).to.be.false;
expect(matchUrl('http://google.com', r)).to.be.true;
expect(matchUrl('google.com/', r)).to.be.true;
expect(matchUrl('docs.google.com', r)).to.be.true;
expect(matchUrl('http://docs.google.com', r)).to.be.true;
expect(matchUrl('www.docs.google.com', r)).to.be.true;
});
.forEach(r => {
expect(matchUrl('docs.google.com', r)).to.be.false;
expect(matchUrl('https://docs.google.co.uk', r)).to.be.false;
expect(matchUrl('https://docs.google.uk', r)).to.be.false;
expect(matchUrl('http://google.com', r)).to.be.true;
expect(matchUrl('https://google.co.uk', r)).to.be.true;
expect(matchUrl('google.ru/', r)).to.be.true;
});
['docs.google.', 'docs.google.*']
.forEach(r => {
expect(matchUrl('http://google.com', r)).to.be.false;
expect(matchUrl('docs.google', r)).to.be.false;
expect(matchUrl('https://docs.googlee.com', r)).to.be.false;
expect(matchUrl('www.docs.google.co.uk', r)).to.be.false;
expect(matchUrl('http://docs.ggoogle.com', r)).to.be.false;
expect(matchUrl('http://___docs.google.com', r)).to.be.false;
expect(matchUrl('docs.google.en', r)).to.be.true;
expect(matchUrl('http://docs.google.co.uk', r)).to.be.true;
});
.forEach(r => {
expect(matchUrl('http://google.com', r)).to.be.false;
expect(matchUrl('docs.google.com', r)).to.be.true;
expect(matchUrl('http://docs.google.com', r)).to.be.true;
expect(matchUrl('www.docs.google.com', r)).to.be.true;
expect(matchUrl('www.my.docs.google.com', r)).to.be.true;
});
['.docs.google.', '.docs.google.']
.forEach(r => {
expect(matchUrl('http://google.com', r)).to.be.false;
expect(matchUrl('docs.google.com', r)).to.be.false;
expect(matchUrl('http://docs.google.com', r)).to.be.false;
expect(matchUrl('www.docs.google.com', r)).to.be.true;
expect(matchUrl('www.my.docs.google.com.eu', r)).to.be.true;
});
expect(matchUrl('docs.google.com', rule)).to.be.true;
expect(matchUrl('docs.google.eu.com', rule)).to.be.true;
expect(matchUrl('docs.google.ru', rule)).to.be.false;
expect(matchUrl('docs.google.co.uk', rule)).to.be.false;
expect(matchUrl('docs.google.com', rule)).to.be.false;
expect(matchUrl('docs.google.ru', rule)).to.be.false;
expect(matchUrl('my.docs.google.ro.eu.com', rule)).to.be.false;
expect(matchUrl('docs.google.co.uk', rule)).to.be.false;
expect(matchUrl('docs.google.eu.com', rule)).to.be.true;
expect(matchUrl('docs.google.ro.eu.com', rule)).to.be.true;
expect(matchUrl('my.docs.google.eu.com.ru', rule)).to.be.true;
expect(matchUrl('docs.google.com', rule)).to.be.false;
expect(matchUrl('localhost', rule)).to.be.true;
expect(matchUrl('http://localhost', rule)).to.be.true;
expect(matchUrl('my-localhost', rule)).to.be.false;
expect(matchUrl('localhost-my', rule)).to.be.false;
expect(matchUrl('127.0.0.1', rule)).to.be.true;
expect(matchUrl('http://127.0.0.1', rule)).to.be.true;
expect(matchUrl('https://127.0.0.1', rule)).to.be.true;
expect(matchUrl('127.127.0.0', rule)).to.be.false;
expect(matchUrl('127.0.0.2', rule)).to.be.true;
expect(matchUrl('127.0.1.2', rule)).to.be.false;
expect(matchUrl('127.0.0.2', rule)).to.be.true;
expect(matchUrl('128.120.120.0', rule)).to.be.false;
expect(matchUrl('127.0.0.0', rule)).to.be.true;
expect(matchUrl('127.120.120.0', rule)).to.be.true;
expect(matchUrl('google.com', rule)).to.be.false;
expect(matchUrl('google.com:80', rule)).to.be.false;
expect(matchUrl('google.com:81', rule)).to.be.true;
expect(matchUrl('google.com', rule)).to.be.false;
expect(matchUrl('google.com:80', rule)).to.be.false;
expect(matchUrl('google.com:81', rule)).to.be.true;
expect(matchUrl('localhost:3000/features/functional/local', rule)).to.be.true;
expect(matchUrl('http://localhost:3000/features/functional/local', rule)).to.be.true;
expect(matchUrl(null, rule)).to.be.false;
expect(matchUrl('google', rule)).to.be.false;