Skip to content

Commit 1b0389e

Browse files
committed
Release 1.0.7
* fix(path-builder): fix #23. Build root path (#25) * fix(package.json): add npm keywords. fix #24 * 1.0.6 (#27) * fix(paths-filter): return array with uniq paths (#29) * 1.0.7 (#30)
1 parent 24d52a2 commit 1b0389e

File tree

3 files changed

+24
-3
lines changed

3 files changed

+24
-3
lines changed

lib/paths-filter/index.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,18 @@ export default (paths = [], rules = [], isValidRules = false) => {
3939
paths = params.paths;
4040
rules = params.rules;
4141

42-
return paths.filter(path => {
42+
return paths.filter((path, index) => {
4343

4444
path = path.trim();
4545

4646
if (!path.length) {
4747
return false;
4848
}
4949

50-
return rules.some(regex => regex.test(path)) === isValidRules;
50+
const isUniq = paths.indexOf(path) === index;
51+
const isValid = rules.some(regex => regex.test(path)) === isValidRules;
52+
53+
return isUniq && isValid;
5154

5255
});
5356

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-router-sitemap",
3-
"version": "1.0.6",
3+
"version": "1.0.7",
44
"description": "Module to generate a sitemap for react-router configuration",
55
"repository": {
66
"type": "git",

test/spec/paths-filter/index.spec.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,4 +57,22 @@ describe('paths filter', () => {
5757

5858
});
5959

60+
it('return uniq paths', () => {
61+
62+
const paths = [
63+
'/path-one',
64+
'/path-one',
65+
'/path-two',
66+
'/path-two',
67+
];
68+
69+
const etalon = [
70+
'/path-one',
71+
'/path-two',
72+
];
73+
74+
expect(filterPaths(paths)).toEqual(etalon);
75+
76+
});
77+
6078
});

0 commit comments

Comments
 (0)