Skip to content

Commit b2b63e5

Browse files
escapedcatmarionebl
authored andcommitted
fix: slash in scope #291 (#529)
* test(rules): add test for slash in scope #291 * fix(ensure): split input by slashes for casing * chore: remove comment
1 parent 3141882 commit b2b63e5

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

@commitlint/ensure/src/case.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,11 @@ function ensureCase(raw = '', target = 'lowercase') {
88
const input = String(raw)
99
.replace(/`.*?`|".*?"|'.*?'/g, '')
1010
.trim();
11-
const transformed = toCase(input, target);
11+
12+
const delimiters = /(\/|\\)/g;
13+
const transformed = input.split(delimiters)
14+
.map(segment => delimiters.test(segment) ? segment : toCase(segment, target))
15+
.join('');
1216

1317
if (transformed === '' || transformed.match(/^\d/)) {
1418
return true;

@commitlint/ensure/src/case.test.js

+5
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,11 @@ test('true for * on pascal-case', t => {
110110
t.is(actual, true);
111111
});
112112

113+
test('true for Modules/Graph on pascal-case', t => {
114+
const actual = ensure('Modules/Graph', 'pascal-case');
115+
t.is(actual, true);
116+
});
117+
113118
test('true for * on start-case', t => {
114119
const actual = ensure('*', 'start-case');
115120
t.is(actual, true);

0 commit comments

Comments
 (0)