index.js 547 B

12345678910111213141516171819202122232425
  1. /*!
  2. * is-glob <https://github.com/jonschlinkert/is-glob>
  3. *
  4. * Copyright (c) 2014-2016, Jon Schlinkert.
  5. * Licensed under the MIT License.
  6. */
  7. var isExtglob = require('is-extglob');
  8. module.exports = function isGlob(str) {
  9. if (typeof str !== 'string' || str === '') {
  10. return false;
  11. }
  12. if (isExtglob(str)) return true;
  13. var regex = /(\\).|([*?]|\[.*\]|\{.*\}|\(.*\|.*\)|^!)/;
  14. var match;
  15. while ((match = regex.exec(str))) {
  16. if (match[2]) return true;
  17. str = str.slice(match.index + match[0].length);
  18. }
  19. return false;
  20. };