示例#1
0
 t.test('should match exact', q => {
   const script = buildScript({
     meta: {
       match: [
         'https://www.google.com/a/b/c',
       ],
     },
   });
   q.ok(testScript('https://www.google.com/a/b/c', script), 'should match exact');
   q.notOk(testScript('https://www.google.com/a/b/c/d', script), 'should match exact');
   q.end();
 });
示例#2
0
 t.test('should match all', q => {
   const script = buildScript({
     meta: {
       match: [
         '*://*/*',
       ],
     },
   });
   q.ok(testScript('https://www.google.com/', script), 'should match `http | https`');
   q.notOk(testScript('file:///Users/Gerald/file', script), 'should not match `file`');
   q.end();
 });
示例#3
0
 t.test('should match any', q => {
   const script = buildScript({
     meta: {
       match: [
         'https://www.google.com/*',
       ],
     },
   });
   q.ok(testScript('https://www.google.com/', script), 'should match `/`');
   q.ok(testScript('https://www.google.com/hello/world', script), 'should match any');
   q.end();
 });
示例#4
0
 t.test('should include any', q => {
   const script = buildScript({
     meta: {
       include: [
         '*',
       ],
     },
   });
   q.ok(testScript('https://www.google.com/', script), 'should match `http | https`');
   q.ok(testScript('file:///Users/Gerald/file', script), 'should match `file`');
   q.end();
 });
示例#5
0
 t.test('should match domain', q => {
   const script = buildScript({
     meta: {
       match: [
         '*://docs.google.com/',
       ],
     },
   });
   q.ok(testScript('https://docs.google.com/', script), 'should match exact domain name');
   q.notOk(testScript('https://sub.docs.google.com/', script), 'should not match subdomains');
   q.notOk(testScript('https://docs.google.com.cn/', script), 'should not match suffixed domains');
   q.end();
 });
示例#6
0
 t.test('should support magic TLD', q => {
   const script = buildScript({
     meta: {
       exclude: [
         'https://www.google.tld/*',
       ],
     },
   });
   q.notOk(testScript('https://www.google.com/', script), 'should match `.com`');
   q.notOk(testScript('https://www.google.com.hk/', script), 'should match `.com.hk`');
   q.ok(testScript('https://www.google.example.com/', script), 'should not match subdomains');
   q.end();
 });
示例#7
0
 t.test('should match subdomains', q => {
   const script = buildScript({
     meta: {
       match: [
         '*://*.google.com/',
       ],
     },
   });
   q.ok(testScript('https://www.google.com/', script), 'should match subdomains');
   q.ok(testScript('https://a.b.google.com/', script), 'should match subdomains');
   q.ok(testScript('https://google.com/', script), 'should match specified domain');
   q.notOk(testScript('https://www.google.com.hk/', script), 'should not match suffixed domains');
   q.end();
 });
示例#8
0
 t.test('should include by regexp', q => {
   const script = buildScript({
     meta: {
       include: [
         'https://www.google.com/*',
         'https://twitter.com/*',
       ],
     },
   });
   q.ok(testScript('https://www.google.com/', script), 'should match `/`');
   q.ok(testScript('https://www.google.com/hello/world', script), 'include by prefix');
   q.notOk(testScript('https://www.hello.com/', script), 'not include by prefix');
   q.end();
 });
示例#9
0
 t.test('should ignore original rules', q => {
   const script = buildScript({
     custom: {
       match: [
         'https://twitter.com/*',
       ],
     },
     meta: {
       match: [
         'https://www.google.com/*',
       ],
     },
   });
   q.ok(testScript('https://twitter.com/', script), 'should match custom rules');
   q.notOk(testScript('https://www.google.com/', script), 'should not match original rules');
   q.end();
 });
示例#10
0
 t.test('should exclude any', q => {
   const script = buildScript({
     meta: {
       match: [
         '*://*/*',
       ],
       excludeMatch: [
         '*://*/*',
       ],
     },
   });
   q.notOk(testScript('https://www.google.com/', script), 'should exclude `http | https`');
   q.end();
 });