diff --git a/selenoid/docker.go b/selenoid/docker.go index 805ffcf..e24535a 100644 --- a/selenoid/docker.go +++ b/selenoid/docker.go @@ -24,6 +24,7 @@ import ( "strings" "time" + "regexp" "runtime" . "vbom.ml/util/sortorder" ) @@ -478,7 +479,14 @@ func (c *DockerConfigurator) getVolumeConfigDir(elem []string) string { // According to https://stackoverflow.com/questions/34161352/docker-sharing-a-volume-on-windows-with-docker-toolbox func postProcessPath(path string) string { - return "/" + strings.Replace(strings.Replace(path, string("\\"), "/", -1), ":", "", 1) + if len(path) >= 2 { + replacedSlashes := strings.Replace(path, string("\\"), "/", -1) + re := regexp.MustCompile("([A-Z]):(.+)") + lowerCaseDriveLetter := strings.ToLower(re.ReplaceAllString(replacedSlashes, "$1")) + pathTail := re.ReplaceAllString(replacedSlashes, "$2") + return "/" + lowerCaseDriveLetter + pathTail + } + return path } func chooseVolumeConfigDir(defaultConfigDir string, elem []string) string { diff --git a/selenoid/docker_test.go b/selenoid/docker_test.go index d80e2ec..badfba9 100644 --- a/selenoid/docker_test.go +++ b/selenoid/docker_test.go @@ -387,6 +387,8 @@ func TestChooseVolumeConfigDir(t *testing.T) { } func TestPostProcessPath(t *testing.T) { - AssertThat(t, postProcessPath("c:\\Users\\admin"), EqualTo{"/c/Users/admin"}) - AssertThat(t, postProcessPath("c:\\c:\\Users\\admin"), EqualTo{"/c/c:/Users/admin"}) + AssertThat(t, postProcessPath("C:\\Users\\admin"), EqualTo{"/c/Users/admin"}) + AssertThat(t, postProcessPath("C:\\C:\\Users\\admin"), EqualTo{"/c/C:/Users/admin"}) + AssertThat(t, postProcessPath("1"), EqualTo{"1"}) + AssertThat(t, postProcessPath(""), EqualTo{""}) }