checkHost.js 330 B

123456789101112
  1. function isRegExp(obj) {
  2. return Object.prototype.toString.call(obj) === '[object RegExp]';
  3. }
  4. export default function checkHost(host, matches) {
  5. for (var i = 0; i < matches.length; i++) {
  6. var match = matches[i];
  7. if (host === match || isRegExp(match) && match.test(host)) {
  8. return true;
  9. }
  10. }
  11. return false;
  12. }