Skip to content

Commit

Permalink
Parse http URLs properly.
Browse files Browse the repository at this point in the history
  • Loading branch information
ernstvonoelsen committed Dec 3, 2024
1 parent b67572b commit 92f3d96
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions pkg/files/file.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,12 @@ func NewSortedFilesFromPaths(paths []string, opts SymlinkAllowOpts) ([]*File, er

relativePath := ""
pathPieces := strings.Split(path, "=")
if strings.HasPrefix(pathPieces[0], "http://") || strings.HasPrefix(pathPieces[0], "https://") {
pathPieces = []string{path}
} else if len(pathPieces) > 1 && (strings.HasPrefix(pathPieces[1], "http://") || strings.HasPrefix(pathPieces[1], "https://")) {
pathPieces[1] = strings.Join(pathPieces[1:], "=")
pathPieces = pathPieces[0:2]
}

switch len(pathPieces) {
case 1:
Expand All @@ -71,6 +77,7 @@ func NewSortedFilesFromPaths(paths []string, opts SymlinkAllowOpts) ([]*File, er

case strings.HasPrefix(path, "http://") || strings.HasPrefix(path, "https://"):
file, err := NewFileFromSource(NewCachedSource(NewHTTPSource(path)))
file.relPath = strings.Split(file.relPath, "?")[0]
if err != nil {
return nil, err
}
Expand Down

0 comments on commit 92f3d96

Please sign in to comment.