1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
import { includes } from 'shared/blacklists';
describe("shared/blacklist", () => {
it('matches by *', () => {
let blacklist = ['*'];
expect(includes(blacklist, 'https://github.com/abc')).to.be.true;
})
it('matches by hostname', () => {
let blacklist = ['github.com'];
expect(includes(blacklist, 'https://github.com')).to.be.true;
expect(includes(blacklist, 'https://gist.github.com')).to.be.false;
expect(includes(blacklist, 'https://github.com/ueokande')).to.be.true;
expect(includes(blacklist, 'https://github.org')).to.be.false;
expect(includes(blacklist, 'https://google.com/search?q=github.org')).to.be.false;
})
it('matches by hostname with wildcard', () => {
let blacklist = ['*.github.com'];
expect(includes(blacklist, 'https://github.com')).to.be.false;
expect(includes(blacklist, 'https://gist.github.com')).to.be.true;
})
it('matches by path', () => {
let blacklist = ['github.com/abc'];
expect(includes(blacklist, 'https://github.com/abc')).to.be.true;
expect(includes(blacklist, 'https://github.com/abcdef')).to.be.false;
expect(includes(blacklist, 'https://gist.github.com/abc')).to.be.false;
})
it('matches by path with wildcard', () => {
let blacklist = ['github.com/abc*'];
expect(includes(blacklist, 'https://github.com/abc')).to.be.true;
expect(includes(blacklist, 'https://github.com/abcdef')).to.be.true;
expect(includes(blacklist, 'https://gist.github.com/abc')).to.be.false;
})
it('matches address and port', () => {
let blacklist = ['127.0.0.1:8888'];
expect(includes(blacklist, 'http://127.0.0.1:8888/')).to.be.true;
expect(includes(blacklist, 'http://127.0.0.1:8888/hello')).to.be.true;
})
});
|