How to use the matcher.isMatch function in matcher

To help you get started, we’ve selected a few matcher examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github eggjs / egg-security / lib / utils.js View on Github external
return domain_white_list.some(rule => {

    // Check whether we've got '*' as a wild character symbol
    if (rule.includes('*')) {
      return matcher.isMatch(domain, rule);
    }
    // If domain is an absolute path such as `http://...`
    // We can directly check whether it directly equals to `domain`
    // And we don't need to cope with `endWith`.
    return domain === rule || hostname.endsWith(rule);
  });
};
github liamray / nexl-js / backend / api / webhooks.js View on Github external
webhooks.forEach(webhook => {
		if (webhook.isDisabled === true) {
			logger.log.debug(`Skipping a [${webhook.relativePath}] webhook because it's disabled`);
			return;
		}

		// checking is webhook matches a target resource
		const opts = {
			caseSensitive: os.platform() !== 'win32'
		};
		if (matcher.isMatch(target.relativePath, webhook.relativePath, opts)) {
			postWebhook(webhook, target);
		} else {
			logger.log.debug(`The [${webhook.relativePath}] webhook doesn't match to [${target.relativePath}] resource`);
		}
	});
	return Promise.resolve();
github neoclide / coc.nvim / lib / source / file.js View on Github external
return files.filter(f => {
            if (f == null)
                return false;
            if (ignoreHidden && /^\./.test(f))
                return false;
            for (let p of ignorePatterns) {
                if (matcher.isMatch(f, p))
                    return false;
            }
            return true;
        });
    }
github gajus / global-agent / src / utilities / isUrlMatchingNoProxy.js View on Github external
const rules = noProxy.split(/[,\s]/);

  for (const rule of rules) {
    const ruleMatch = rule
      .replace(/^(?\.)/, '*')
      .match(/^(?.+?)(?::(?\d+))?$/);

    if (!ruleMatch || !ruleMatch.groups) {
      throw new UnexpectedStateError('Invalid NO_PROXY pattern.');
    }

    if (!ruleMatch.groups.hostname) {
      throw new UnexpectedStateError('NO_PROXY entry pattern must include hostname. Use * to match any hostname.');
    }

    const hostnameIsMatch = matcher.isMatch(subjectUrlTokens.hostname, ruleMatch.groups.hostname);

    if (hostnameIsMatch && (!ruleMatch.groups || !ruleMatch.groups.port || subjectUrlTokens.port && subjectUrlTokens.port === ruleMatch.groups.port)) {
      return true;
    }
  }

  return false;
};
github typicode / hotel / src / daemon / vhosts / utils / get-server-id.js View on Github external
.map(h => ({
      host: h,
      strict: matcher.isMatch(host, h),
      wildcard: matcher.isMatch(host, `*.${h}`)
    }))
github typicode / hotel / src / daemon / group.js View on Github external
.map(h => ({
        host: h,
        isStrictMatch: matcher.isMatch(str, h),
        isWildcardMatch: matcher.isMatch(str, `*.${h}`)
      }))
github typicode / hotel / src / daemon / group.js View on Github external
.map(h => ({
        host: h,
        isStrictMatch: matcher.isMatch(str, h),
        isWildcardMatch: matcher.isMatch(str, `*.${h}`)
      }))
github staart / api / src / helpers / mail.ts View on Github external
    d => (isDisposable = isDisposable || isMatch(email, `*.${d}`))
  );