Skip to content

Commit

Permalink
Merge pull request #9 from 2manymws/fix-bugs-null
Browse files Browse the repository at this point in the history
fix null pattern
  • Loading branch information
pyama86 authored Dec 26, 2023
2 parents 5cdbe0d + 49d6079 commit e0a68d6
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 e0a68d6

Please sign in to comment.