Skip to content

Commit

Permalink
fix windows url parse
Browse files Browse the repository at this point in the history
  • Loading branch information
dduzgun-security committed Jan 10, 2025
1 parent bb6ad0a commit 168f391
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
7 changes: 4 additions & 3 deletions detect_gcs.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ package getter

import (
"fmt"
"net/url"
"strings"

urlhelper "github.com/hashicorp/go-getter/helper/url"
)

// GCSDetector implements Detector to detect GCS URLs and turn
Expand All @@ -22,7 +23,7 @@ func (d *GCSDetector) Detect(src, _ string) (string, bool, error) {
src = "https://" + src
}

parsedURL, err := url.Parse(src)
parsedURL, err := urlhelper.Parse(src)
if err != nil {
return "", false, fmt.Errorf("error parsing GCS URL")
}
Expand All @@ -45,7 +46,7 @@ func (d *GCSDetector) detectHTTP(src string) (string, bool, error) {
bucket := parts[3]
object := strings.Join(parts[4:], "/")

url, err := url.Parse(fmt.Sprintf("https://www.googleapis.com/storage/%s/%s/%s",
url, err := urlhelper.Parse(fmt.Sprintf("https://www.googleapis.com/storage/%s/%s/%s",
version, bucket, object))
if err != nil {
return "", false, fmt.Errorf("error parsing GCS URL: %s", err)
Expand Down
11 changes: 6 additions & 5 deletions detect_s3.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ package getter

import (
"fmt"
"net/url"
"strings"

urlhelper "github.com/hashicorp/go-getter/helper/url"
)

// S3Detector implements Detector to detect S3 URLs and turn
Expand All @@ -22,7 +23,7 @@ func (d *S3Detector) Detect(src, _ string) (string, bool, error) {
src = "https://" + src
}

parsedURL, err := url.Parse(src)
parsedURL, err := urlhelper.Parse(src)
if err != nil {
return "", false, fmt.Errorf("error parsing S3 URL")
}
Expand Down Expand Up @@ -56,7 +57,7 @@ func (d *S3Detector) detectHTTP(src string) (string, bool, error) {

func (d *S3Detector) detectPathStyle(region string, parts []string) (string, bool, error) {
urlStr := fmt.Sprintf("https://%s.amazonaws.com/%s", region, strings.Join(parts, "/"))
url, err := url.Parse(urlStr)
url, err := urlhelper.Parse(urlStr)
if err != nil {
return "", false, fmt.Errorf("error parsing S3 URL: %s", err)
}
Expand All @@ -66,7 +67,7 @@ func (d *S3Detector) detectPathStyle(region string, parts []string) (string, boo

func (d *S3Detector) detectVhostStyle(region, bucket string, parts []string) (string, bool, error) {
urlStr := fmt.Sprintf("https://%s.amazonaws.com/%s/%s", region, bucket, strings.Join(parts, "/"))
url, err := url.Parse(urlStr)
url, err := urlhelper.Parse(urlStr)
if err != nil {
return "", false, fmt.Errorf("error parsing S3 URL: %s", err)
}
Expand All @@ -76,7 +77,7 @@ func (d *S3Detector) detectVhostStyle(region, bucket string, parts []string) (st

func (d *S3Detector) detectNewVhostStyle(region, bucket string, parts []string) (string, bool, error) {
urlStr := fmt.Sprintf("https://s3.%s.amazonaws.com/%s/%s", region, bucket, strings.Join(parts, "/"))
url, err := url.Parse(urlStr)
url, err := urlhelper.Parse(urlStr)
if err != nil {
return "", false, fmt.Errorf("error parsing S3 URL: %s", err)
}
Expand Down

0 comments on commit 168f391

Please sign in to comment.