diff options
author | Shin'ya Ueoka <ueokande@i-beam.org> | 2017-10-23 10:43:33 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-10-23 10:43:33 +0000 |
commit | ccc81312a1d4d9a5cea7d7451c26ec25b2172aa8 (patch) | |
tree | 96ae119fb5e7939547284f72fc12cd9cc6c717d5 /test/shared/util/re.test.js | |
parent | 7639e99b755e372712dca36e077a85d9a025cd9f (diff) | |
parent | b9f2668ceab3d786ce3e587803ff30ec5c781ee3 (diff) |
Merge pull request #90 from ueokande/11-url-blacklist
URL blacklist
Diffstat (limited to 'test/shared/util/re.test.js')
-rw-r--r-- | test/shared/util/re.test.js | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/test/shared/util/re.test.js b/test/shared/util/re.test.js new file mode 100644 index 0000000..9ed6521 --- /dev/null +++ b/test/shared/util/re.test.js @@ -0,0 +1,20 @@ +import { expect } from 'chai'; +import * as re from 'shared/utils/re'; + +describe("re util", () => { + it('matches by pattern', () => { + let regex = re.fromWildcard('*.example.com/*'); + expect('foo.example.com/bar').to.match(regex); + expect('foo.example.com').not.to.match(regex); + expect('example.com/bar').not.to.match(regex); + + regex = re.fromWildcard('example.com/*') + expect('example.com/foo').to.match(regex); + expect('example.com/').to.match(regex); + + regex = re.fromWildcard('example.com/*bar') + expect('example.com/foobar').to.match(regex); + expect('example.com/bar').to.match(regex); + expect('example.com/foobarfoo').not.to.match(regex); + }) +}); |