Skip to content

Commit 3b56be2

Browse files
committed
fix: if the path is equal to just a single slash do not count it as a violation
1 parent ad10be6 commit 3b56be2

2 files changed

Lines changed: 17 additions & 1 deletion

File tree

src/main/java/cli/rule/rules/TrailingRule.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,14 @@ private List<Violation> checkForTrailingSlashes(Set<String> paths) {
7474
for (String path : paths) {
7575
Output.progressPercentage(curPath, totalPaths);
7676
curPath++;
77+
// if the path is the root path, skip it
78+
// see https://github.com/restful-ma/rest-ruler/issues/52 for more information
79+
if (path.equals("/")) {
80+
continue;
81+
}
7782
if (path.endsWith("/")) {
78-
violations.add(new Violation(this, RestAnalyzer.locMapper.getLOCOfPath(path), ImprovementSuggestion.TRAILING_SLASH,
83+
violations.add(new Violation(this, RestAnalyzer.locMapper.getLOCOfPath(path),
84+
ImprovementSuggestion.TRAILING_SLASH,
7985
path, ErrorMessage.TRAILINGSLASH));
8086
}
8187
}

src/test/java/cli/rule/tunnelingTests/InvalidOpenAPITrailingRule.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,16 @@
6060
}
6161
],
6262
"paths": {
63+
"/": {
64+
"get": {
65+
"description": "Root endpoint",
66+
"responses": {
67+
"200": {
68+
"description": "OK"
69+
}
70+
}
71+
}
72+
},
6373
"/getadult/": {
6474
"post": {
6575
"consumes": [

0 commit comments

Comments
 (0)