-
Notifications
You must be signed in to change notification settings - Fork 3
feat: Add support for http://example.com #17
Conversation
"tcp://127.0.0.1:xxx", | ||
Endpoint{}, | ||
ErrInvalidValue, | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add test cases like:
file:///tmp/test
@@ -33,6 +33,12 @@ func TestParse(t *testing.T) { | |||
Endpoint{ProtocolHTTP, hostPort{"example.com", 80}}, | |||
nil, | |||
}, | |||
{ | |||
"normal http with multi /", | |||
"http://////example.com:80", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be invalid?
endpoint.go
Outdated
@@ -44,6 +44,10 @@ func Parse(cfg string) (p Endpoint, err error) { | |||
// Handle file paths that contains ":" (often happens on windows platform) | |||
// | |||
// See issue: https://github.com/beyondstorage/go-endpoint/issues/3 | |||
s[1] = strings.TrimLeft(s[1], "/") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Compared to handle them in different protocol cases, how about handling all of them? Maybe we can operate on s[1]
directly?
@Xuanwo I tried using address like http:////74.125.128.160:80 to visit google,it's valid. |
They may be valid for the browser, but they are not valid according to RFC3986: https://datatracker.ietf.org/doc/html/rfc3986#section-3 |
@Xuanwo |
Please statement it more clear. Which problem could happen? |
If handling all of them together, we have to consider several situations in one method.The logic may be complex.One process may be entangled with another. It's hard to read and maintain. |
Let's discuss them here now. From my point of view, we only need to check like the following: if strings.HasPrefix(s[1], "//") {
s[1] = s[1][2:]
} Please correct me if there are other situations I missed. |
|
We will return errors for invalid input. For example, we can return an error if |
Oh, so accutualy we can process s[1] before switch s[0].Then we don't have to change the method parseHostPort. |
100% correct. Besides, we don't need a |
Much better! Thanks for your hard working! |
fix:Add support for :// #15