Skip to content

Commit

Permalink
fix: slash in scope #291 (#529)
Browse files Browse the repository at this point in the history
* test(rules): add test for slash in scope #291

* fix(ensure): split input by slashes for casing

* chore: remove comment
  • Loading branch information
escapedcat authored and marionebl committed Jan 27, 2019
1 parent 3141882 commit b2b63e5
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
6 changes: 5 additions & 1 deletion @commitlint/ensure/src/case.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@ function ensureCase(raw = '', target = 'lowercase') {
const input = String(raw)
.replace(/`.*?`|".*?"|'.*?'/g, '')
.trim();
const transformed = toCase(input, target);

const delimiters = /(\/|\\)/g;
const transformed = input.split(delimiters)
.map(segment => delimiters.test(segment) ? segment : toCase(segment, target))
.join('');

if (transformed === '' || transformed.match(/^\d/)) {
return true;
Expand Down
5 changes: 5 additions & 0 deletions @commitlint/ensure/src/case.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,11 @@ test('true for * on pascal-case', t => {
t.is(actual, true);
});

test('true for Modules/Graph on pascal-case', t => {
const actual = ensure('Modules/Graph', 'pascal-case');
t.is(actual, true);
});

test('true for * on start-case', t => {
const actual = ensure('*', 'start-case');
t.is(actual, true);
Expand Down

0 comments on commit b2b63e5

Please sign in to comment.