Skip to content

Commit 1151bc5

Browse files
committed
Address #27 fully
1 parent 04d2b62 commit 1151bc5

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

paths/paths.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ func checkPathAgainstBase(docPath, urlPath string, basePaths []string) bool {
174174
return true
175175
}
176176
for _, basePath := range basePaths {
177-
if basePath[len(basePath)-1] == '/' {
177+
if len(basePath) > 1 && basePath[len(basePath)-1] == '/' {
178178
basePath = basePath[:len(basePath)-1]
179179
}
180180
merged := fmt.Sprintf("%s%s", basePath, urlPath)

paths/paths_test.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1480,6 +1480,11 @@ func TestCheckPathAgainstBase_MergedPath(t *testing.T) {
14801480
// No match
14811481
result = checkPathAgainstBase("/other/path", "/users", basePaths)
14821482
assert.False(t, result)
1483+
1484+
// Issue #27: basePath is just "/" — should not produce empty string
1485+
basePaths = []string{"/"}
1486+
result = checkPathAgainstBase("/users", "/users", basePaths)
1487+
assert.True(t, result)
14831488
}
14841489

14851490
func TestFindPath_RegexFallback_MethodMismatch(t *testing.T) {

0 commit comments

Comments
 (0)