We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
// go-ethereum/accounts/url.go func parseURL(url string) (URL, error) { parts := strings.Split(url, "://") if len(parts) != 2 || parts[0] == "" { return URL{}, errors.New("protocol scheme missing") } return URL{ Scheme: parts[0], Path: parts[1], }, nil }
// go-ethereum/accounts/url_test.go func TestURLParsing(t *testing.T) { url, err := parseURL("https://ethereum.org") if err != nil { t.Errorf("unexpected error: %v", err) } if url.Scheme != "https" { t.Errorf("expected: %v, got: %v", "https", url.Scheme) } if url.Path != "ethereum.org" { t.Errorf("expected: %v, got: %v", "ethereum.org", url.Path) } _, err = parseURL("ethereum.org") if err == nil { t.Error("expected err, got: nil") } }
url_test.go is checking this part,
len(parts) != 2
But, doesn't check this,
parts[0] == ""
I think, it would be nice to add this logic.
// go-ethereum/accounts/url_test.go func TestURLParsing(t *testing.T) { url, err := parseURL("https://ethereum.org") if err != nil { t.Errorf("unexpected error: %v", err) } if url.Scheme != "https" { t.Errorf("expected: %v, got: %v", "https", url.Scheme) } if url.Path != "ethereum.org" { t.Errorf("expected: %v, got: %v", "ethereum.org", url.Path) } _, err = parseURL("ethereum.org") if err == nil { t.Error("expected err, got: nil") } // here _, err = parseURL("") if err == nil { t.Error("expected err, got: nil") } }
thanks.
The text was updated successfully, but these errors were encountered:
makes sense - can you PR it?
Sorry, something went wrong.
No branches or pull requests
url_test.go is checking this part,
But, doesn't check this,
I think, it would be nice to add this logic.
thanks.
The text was updated successfully, but these errors were encountered: