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

1) Fixed URL segment separator issue. in GetPackageByName() preventing use on Microsoft Windows. #7

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion dependency/repository/packagist.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ func NewPackagist(instance string, httpClient *http.Client) (*PackagistClient, e

// GetPackageByName returns a package by a given name
func (c *PackagistClient) GetPackageByName(name string) (*PackagistPackage, *http.Response, error) {
u := fmt.Sprintf("%s/packages%s.json", c.url.String(), filepath.Clean("/"+name))
u := fmt.Sprintf("%s/packages%s.json", c.url.String(), strings.Replace(filepath.Clean("/"+name), "\\", "/", -1))
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In #6 (comment) you pointed out that the issue might be the usage of filepath.Clean. What do you think about removing the filepath.Clean reference and replacing it with an URL fitting pattern? e.g. typical URL encoding?
Have a look at https://www.urlencoder.io/golang/ to check if one of those might be a good choice.

resp, err := c.httpClient.Get(u)
if err != nil {
return nil, resp, err
Expand Down