Skip to content

Commit

Permalink
make sure env vars are expanded in http req headers, refactor middleware
Browse files Browse the repository at this point in the history
  • Loading branch information
patinthehat committed Aug 5, 2023
1 parent 8426317 commit e9096eb
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
5 changes: 4 additions & 1 deletion lib/gateway/gateway.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"io"
"net/http"
"net/url"
"os"
"strings"
"sync"

Expand Down Expand Up @@ -147,13 +148,15 @@ func (g *Gateway) GetUrl(urlStr string, headers ...string) (string, error) {
g.DomainHeaders.Range(func(key, value any) bool {
parsed, _ := url.Parse(urlStr)
if glob.Glob(key.(string), parsed.Hostname()) {
tempHeaders = append(tempHeaders, value.(string))
header := os.ExpandEnv(value.(string))
tempHeaders = append(tempHeaders, header)
}
return true
})

for _, header := range headers {
if strings.TrimSpace(header) != "" {
header = os.ExpandEnv(header)
tempHeaders = append(tempHeaders, header)
}
}
Expand Down
2 changes: 1 addition & 1 deletion lib/gateway/middleware.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ func verifyFileTypeHandler(g *Gateway, link string) error {
}

allowedFileNames := []string{"checksums.txt", "checksums.sha256.txt", "checksums.sha512.txt", "sha256sum", "sha512sum"}
allowedExts := []string{".yaml", ".yml", ".txt", ".sha256", ".sha512"}
allowedExts := []string{".yaml", ".yml", ".txt", ".sha256", ".sha512", ".json", ".js"}

for _, name := range allowedFileNames {
if strings.EqualFold(baseName, name) {
Expand Down

0 comments on commit e9096eb

Please sign in to comment.