path.matchesGlob(path, pattern)


  • path <string> 要与之进行全局匹配的路径。
  • pattern <string> 用于检查路径的通配符。
  • 返回:<boolean> 表示 path 是否与 pattern 匹配。

path.matchesGlob() 方法用于判断 path 是否匹配 pattern

【The path.matchesGlob() method determines if path matches the pattern.】

例如:

【For example:】

path.matchesGlob('/foo/bar', '/foo/*'); // true
path.matchesGlob('/foo/bar*', 'foo/bird'); // false 

如果 pathpattern 不是字符串,将抛出 TypeError

【A TypeError is thrown if path or pattern are not strings.】