MCPcopy Create free account
hub / github.com/conventional-changelog/commitlint / widenTypeCapture

Function widenTypeCapture

@commitlint/parse/src/index.ts:24–42  ·  view source on GitHub ↗
(pattern: unknown)

Source from the content-addressed store, hash-verified

22const unicodeTypeCapture = "^([\\p{L}\\p{M}\\p{N}_]*)";
23
24function widenTypeCapture(pattern: unknown): unknown {
25 if (
26 !(pattern instanceof RegExp) ||
27 /[uv]/.test(pattern.flags) ||
28 !pattern.source.startsWith(asciiTypeCapture)
29 ) {
30 return pattern;
31 }
32
33 try {
34 return new RegExp(
35 unicodeTypeCapture + pattern.source.slice(asciiTypeCapture.length),
36 pattern.flags + "u",
37 );
38 } catch {
39 // the rest of the pattern is not valid in unicode mode
40 return pattern;
41 }
42}
43
44function widenHeaderPatterns<T extends Record<string, any>>(opts: T): T | null {
45 const widened: Record<string, any> = { ...opts };

Callers 1

widenHeaderPatternsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected