Skip to content
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

Parse the url and remove query #184

Merged
merged 3 commits into from
Nov 24, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion pkg/utils/extensions/extensions.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package extensions

import (
"fmt"
"net/url"
"path"
"strings"
)
Expand Down Expand Up @@ -44,7 +45,13 @@ func NewValidator(extensionsMatch, extensionsFilter []string) *Validator {

// ValidatePath returns true if an extension is allowed by the validator
func (e *Validator) ValidatePath(item string) bool {
extension := strings.ToLower(path.Ext(item))
var extension string
u, _ := url.Parse(item)
if u != nil {
extension = strings.ToLower(path.Ext(u.Path))
} else {
extension = strings.ToLower(path.Ext(item))
}
if extension == "" && len(e.extensionsMatch) > 0 {
return false
}
Expand Down