path.matchesGlob(path, pattern)


版本历史
版本变更
v24.8.0

标记 API 稳定。

v22.5.0, v20.17.0

新增于: v22.5.0, v20.17.0

  • path <string> 用于 glob 匹配的路径。

    \path <string> The path to glob-match against.

  • pattern <string> 用于检查路径的 glob。

    \pattern <string> The glob to check the path against.

  • 返回:<boolean> path 是否与 pattern 匹配。

    \Returns: <boolean> Whether or not the path matched the 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.

AltStyle によって変換されたページ (->オリジナル) /