-
Notifications
You must be signed in to change notification settings - Fork 812
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
blob/fileblob: ignore URL's Host and drop leading / on Windows #644
Conversation
// Host field, so URLs should always start with "file:///". On | ||
// Windows, the leading "/" will be stripped, so "file:///c:/foo" | ||
// will refer to c:/foo. | ||
urlpath := url.PathEscape(filepath.ToSlash(dir)) |
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.
Should we handle converting separators to '/' in package fileblob instead of letting user to it? Is "c:\foo\bar" invalid?
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.
No; according to this, even on Windows, URLs referring to files should use "/" as a path separator. So doing this on the user side is correct.
That said, it might work either way; i.e., if they pass file:///c:\foo\bar.txt
, it might work. "" is definitely illegal in the host part, which is why the test was failing before, but it might be legal in the path part, and we are just passing the path through to OpenBucket
. I don't want to document it as working though., and the example should do the correct thing.
This appears to be more correct than including the Host as part of the string we pass
OpenBucket
, based on my reading of https://en.wikipedia.org/wiki/File_URI_scheme. Dealing with file-based URLs in Windows is pretty hokey, but it's clear you have to drop the leading "/".blob/example_test.go
passes on Windows after these changes.