Skip to main content
Home
This release is 16 versions behind 1.1.4 — the latest version of @std/path. Jump to latest

@std/path@0.225.1
Built and signed on GitHub Actions

Works with
This package works with Cloudflare Workers, Deno, Browsers
This package works with Cloudflare Workers
This package works with Deno
This package works with Browsers
JSR Score94%
Downloads84,290/wk
Published2 years ago (0.225.1)

Utilities for working with file system paths

// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. // This module is browser compatible. /** Test whether the given string is a glob */ export function isGlob(str: string): boolean { const chars: Record<string, string> = { "{": "}", "(": ")", "[": "]" }; const regex = /\\(.)|(^!|\*|\?|[\].+)]\?|\[[^\\\]]+\]|\{[^\\}]+\}|\(\?[:!=][^\\)]+\)|\([^|]+\|[^\\)]+\))/; if (str === "") { return false; } let match: RegExpExecArray | null; while ((match = regex.exec(str))) { if (match[2]) return true; let idx = match.index + match[0].length; // if an open bracket/brace/paren is escaped, // set the index to the next closing character const open = match[1]; const close = open ? chars[open] : null; if (open && close) { const n = str.indexOf(close, idx); if (n !== -1) { idx = n + 1; } } str = str.slice(idx); } return false; }