MCPcopy Create free account
hub / github.com/NomicFoundation/hardhat / namespaceToRegExp

Function namespaceToRegExp

packages/hardhat-utils/src/internal/debug.ts:52–58  ·  view source on GitHub ↗

* Converts a `DEBUG`-style namespace pattern into an anchored regex. * Regex metacharacters are escaped to match literally, and `*` is translated * into `.*?` so it behaves as a glob wildcard.

(namespace: string)

Source from the content-addressed store, hash-verified

50 * into `.*?` so it behaves as a glob wildcard.
51 */
52function namespaceToRegExp(namespace: string): RegExp {
53 const escaped = namespace
54 .replace(/[.+?^${}()|[\]\\]/g, "\\$&")
55 .replace(/\*/g, ".*?");
56
57 return new RegExp(`^${escaped}$`);
58}
59
60/**
61 * Checks whether a namespace is enabled under the given `DEBUG` pattern string.

Callers 1

parsePatternsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected