Fix Windows->inet/Posix path conversion issue.
This commit is contained in:
parent
d5448e2986
commit
0d164708ec
|
@ -238,8 +238,11 @@ struct Path {
|
||||||
return ret;
|
return ret;
|
||||||
} else {
|
} else {
|
||||||
if (m_type == PathType.windows) {
|
if (m_type == PathType.windows) {
|
||||||
if (m_absolute) return '/' ~ this[].map!(n => n.toString()).join('/');
|
string ret;
|
||||||
else return this[].map!(n => n.toString()).join('/');
|
if (m_absolute) ret = '/' ~ this[].map!(n => n.toString()).join('/');
|
||||||
|
else ret = this[].map!(n => n.toString()).join('/');
|
||||||
|
if (endsWithSlash) ret ~= '/';
|
||||||
|
return ret;
|
||||||
} else return m_path;
|
} else return m_path;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -458,6 +461,7 @@ unittest
|
||||||
assert(Path("/C:/Windows", PathType.inet).toString(PathType.windows) == "C:\\Windows");
|
assert(Path("/C:/Windows", PathType.inet).toString(PathType.windows) == "C:\\Windows");
|
||||||
assert((Path("/C:/Windows", PathType.inet) ~ Path("test\\this", PathType.windows)).toString() == "/C:/Windows/test/this");
|
assert((Path("/C:/Windows", PathType.inet) ~ Path("test\\this", PathType.windows)).toString() == "/C:/Windows/test/this");
|
||||||
assert((Path("", PathType.inet) ~ Path("foo\\bar", PathType.windows)).toString() == "foo/bar");
|
assert((Path("", PathType.inet) ~ Path("foo\\bar", PathType.windows)).toString() == "foo/bar");
|
||||||
|
assert(Path("C:\\Windows\\", PathType.windows).toString(PathType.inet) == "/C:/Windows/");
|
||||||
|
|
||||||
assert(Path("").empty);
|
assert(Path("").empty);
|
||||||
assert(Path("a/b/c")[1 .. 3].map!(p => p.toString()).equal(["b", "c"]));
|
assert(Path("a/b/c")[1 .. 3].map!(p => p.toString()).equal(["b", "c"]));
|
||||||
|
|
Loading…
Reference in a new issue