fix(path): agnoster unc path on windows

This commit is contained in:
lnu 2022-04-07 08:43:08 +02:00 committed by Jan De Dobbeleer
parent 3d0e108122
commit 39a272af76
2 changed files with 4 additions and 1 deletions

View file

@ -238,7 +238,7 @@ func (pt *Path) getUniqueLettersPath() string {
func (pt *Path) getAgnosterFullPath() string {
pwd := pt.getPwd()
if len(pwd) > 1 && string(pwd[0]) == pt.env.PathSeparator() {
for len(pwd) > 1 && string(pwd[0]) == pt.env.PathSeparator() {
pwd = pwd[1:]
}
return pt.replaceFolderSeparators(pwd)

View file

@ -267,6 +267,9 @@ func TestAgnosterPathStyles(t *testing.T) {
{Style: Unique, Expected: "~ > a > ab > abcd", HomePath: "/usr/home", Pwd: "/usr/home/ab/abc/abcd", PathSeparator: "/", FolderSeparatorIcon: " > "},
{Style: Unique, Expected: "~ > a > .a > abcd", HomePath: "/usr/home", Pwd: "/usr/home/ab/.abc/abcd", PathSeparator: "/", FolderSeparatorIcon: " > "},
{Style: Unique, Expected: "~ > a > ab > abcd", HomePath: "/usr/home", Pwd: "/usr/home/ab/ab/abcd", PathSeparator: "/", FolderSeparatorIcon: " > "},
{Style: AgnosterShort, Expected: "localhost > c$", HomePath: homeBillWindows, Pwd: "\\\\localhost\\c$", PathSeparator: "\\", FolderSeparatorIcon: " > "},
{Style: AgnosterShort, Expected: "localhost\\c$", HomePath: homeBillWindows, Pwd: "\\\\localhost\\c$", PathSeparator: "\\", FolderSeparatorIcon: "\\"},
}
for _, tc := range cases {
env := new(mock.MockedEnvironment)