-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix null pattern #9
Conversation
@@ -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{}{} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems better to exclude illegal ext.
https://go.dev/play/p/tAFv_4iuCHr
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you saying that having a file extension as "" (empty string) is an abnormal case? I thought that in the context of the web, there are cases where files don't have extensions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's a confusing behavior that the root path is limited to the target file with no file extension.
How about this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There may be a way to change isTargetExtensions as a fix to https://github.com/2manymws/rlutils/pull/9/files#r1436334082
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://github.com/2manymws/rlutils/pull/9/files#r1436334082 is trivial, so this fix looks good.
ref: https://go.dev/play/p/2vZE4pIC-ai
In Go, accessing a[0] when a is an empty string (a := "") will result in a panic.