Merge pull request #1067 from abperiasamy/alias-path-sep

only honor alias for path-separated prefixes
This commit is contained in:
Anand Babu (AB) Periasamy
2015-08-29 18:28:08 -07:00
2 changed files with 6 additions and 6 deletions
+3 -3
View File
@@ -17,9 +17,9 @@
package main
import (
"os"
"regexp"
"strings"
"unicode"
"unicode/utf8"
)
@@ -43,8 +43,8 @@ func aliasExpand(aliasedURL string, aliases map[string]string) string {
if len(splits[0]) == 0 && len(splits[1]) == 0 {
return aliasValue // exact match.
}
separator, _ := utf8.DecodeRuneInString(splits[1])
if unicode.IsLetter(separator) || unicode.IsNumber(separator) {
_, sepLen := utf8.DecodeRuneInString(splits[1])
if sepLen == 1 && !os.IsPathSeparator(splits[1][0]) {
return aliasedURL // Do not expand for whole strings with alias prefix.
}
// Matched, but path needs to be joined.
+3 -3
View File
@@ -173,14 +173,14 @@ func (s *CmdTestSuite) TestHostConfig(c *C) {
}
func (s *CmdTestSuite) TestArgs2URL(c *C) {
URLs := []string{"localhost", "s3", "play", "playgo", "goplay", "https://s3-us-west-2.amazonaws.com"}
URLs := []string{"localhost", "s3", "play", "playgo", "play.go", "https://s3-us-west-2.amazonaws.com"}
expandedURLs, err := args2URLs(URLs)
c.Assert(err, IsNil)
c.Assert(expandedURLs[0], Equals, "http://localhost:9000")
c.Assert(expandedURLs[1], Equals, "https://s3.amazonaws.com")
c.Assert(expandedURLs[2], Equals, "https://play.minio.io:9000")
c.Assert(expandedURLs[3], Equals, "playgo") // Has no corresponding alias. So expect same value.
c.Assert(expandedURLs[4], Equals, "goplay") // Has no corresponding alias. So expect same value.
c.Assert(expandedURLs[3], Equals, "playgo") // Has no corresponding alias. So expect same value.
c.Assert(expandedURLs[4], Equals, "play.go") // Has no corresponding alias. So expect same value.
c.Assert(expandedURLs[5], Equals, "https://s3-us-west-2.amazonaws.com")
}