Repository navigation
Commit eec5be9
authored
fix: Anchor type and scope patterns as a whole (#326)
* fix: Anchor type and scope patterns as a whole
Patterns in `types`, `scopes` and `disallowScopes` are documented as
auto-wrapped in `^ $`, but `^${pattern}$` only anchors the first and the
last alternative of a pattern that contains `|`: `^feat|fix$` means
`(^feat)|(fix$)`. So `types: feat|fix` accepted `feature: x` and
`prefix: x`, `scopes: core|ui` accepted `cores` and `build-ui`, and
`disallowScopes: release|test` rejected `releases` and `mytest`.
Wrap each pattern in a non-capturing group, `^(?:${pattern})$`, so the
whole pattern has to match. Well-formed patterns without `|`, and
patterns already wrapped in `^ $`, behave as before. A malformed pattern
can fail differently: `foo\` now throws as an invalid regex, while
`a)|(b` now compiles.
* test: Add a positive check for patterns with alternatives1 parent 1ee9a55 commit eec5be9
2 files changed
Lines changed: 18 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
51 | 51 | | |
52 | 52 | | |
53 | 53 | | |
54 | | - | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
55 | 57 | | |
56 | 58 | | |
57 | 59 | | |
58 | 60 | | |
59 | 61 | | |
60 | | - | |
| 62 | + | |
61 | 63 | | |
62 | 64 | | |
63 | 65 | | |
| |||
71 | 73 | | |
72 | 74 | | |
73 | 75 | | |
74 | | - | |
| 76 | + | |
75 | 77 | | |
76 | 78 | | |
77 | 79 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
39 | 39 | | |
40 | 40 | | |
41 | 41 | | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
42 | 55 | | |
43 | 56 | | |
44 | 57 | | |
| |||
0 commit comments