Skip to content

Commit

Permalink
fix null pattern
Browse files Browse the repository at this point in the history
  • Loading branch information
pyama86 committed Dec 26, 2023
1 parent 5cdbe0d commit 49d6079
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion base_limiter.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func NewBaseLimiter(
targetExtensionsMap := make(map[string]struct{}, len(targetExtensions))
if len(targetExtensions) > 0 {
for _, ext := range targetExtensions {
if ext[0] != '.' {
if len(ext) > 0 && ext[0] != '.' {
ext = "." + ext
}
targetExtensionsMap[strings.ToLower(ext)] = struct{}{}
Expand Down
6 changes: 6 additions & 0 deletions base_limiter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,12 @@ func TestBaseLimiter_isTargetExtensions(t *testing.T) {
requestPath: "/file",
want: false,
},
{
name: "null extention",
targetExtensions: []string{""},
requestPath: "/file",
want: true,
},
}

for _, tt := range tests {
Expand Down

0 comments on commit 49d6079

Please sign in to comment.