Use const slashSeparator instead of "/" everywhere (#8028)

This commit is contained in:
Harshavardhana
2019-08-06 12:08:58 -07:00
committed by GitHub
parent b52b90412b
commit e6d8e272ce
71 changed files with 298 additions and 293 deletions

View File

@@ -95,8 +95,8 @@ func isMetadataReplace(h http.Header) bool {
// Splits an incoming path into bucket and object components.
func path2BucketAndObject(path string) (bucket, object string) {
// Skip the first element if it is '/', split the rest.
path = strings.TrimPrefix(path, "/")
pathComponents := strings.SplitN(path, "/", 2)
path = strings.TrimPrefix(path, SlashSeparator)
pathComponents := strings.SplitN(path, SlashSeparator, 2)
// Save the bucket and object extracted from path.
switch len(pathComponents) {
@@ -370,7 +370,7 @@ func getResource(path string, host string, domains []string) (string, error) {
continue
}
bucket := strings.TrimSuffix(host, "."+domain)
return slashSeparator + pathJoin(bucket, path), nil
return SlashSeparator + pathJoin(bucket, path), nil
}
return path, nil
}