mirror of
https://github.com/skywind3000/z.lua
synced 2026-10-29 03:54:27 +00:00
passes all tests in path_join
This commit is contained in:
1 parent
5f5df0418b
commit
99529516fb
2 files changed
+10
-8
No files matched your search
@@ -142,6 +142,12 @@ function test_join_windows()
|
||||
assert_join_windows({'c:a/b', 'C:x/y'}, 'C:a/b\\x/y')
|
||||
assert_join_windows({'c:/', 'C:x/y'}, 'C:/x/y')
|
||||
assert_join_windows({'c:/a/b', 'C:x/y'}, 'C:/a/b\\x/y')
|
||||
|
||||
for _, x in ipairs({'', 'a/b', '/a/b', 'c:', 'c:a/b', 'c:/', 'c:/a/b'}) do
|
||||
for _, y in ipairs({'d:', 'd:x/y', 'd:/', 'd:/x/y'}) do
|
||||
assert_join_windows({x, y}, y)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
test_join_posix()
|
||||
|
||||
@@ -542,14 +542,8 @@ function os.path.join(path1, path2)
|
||||
end
|
||||
return path2
|
||||
elseif windows then
|
||||
local d1 = path1:sub(1, 2)
|
||||
local d2 = path2:sub(1, 2)
|
||||
if not path1:match('^%a:') then
|
||||
d1 = ''
|
||||
end
|
||||
if not path2:match('^%a:') then
|
||||
d2 = ''
|
||||
end
|
||||
local d1 = path1:match('^%a:') and path1:sub(1, 2) or ''
|
||||
local d2 = path2:match('^%a:') and path2:sub(1, 2) or ''
|
||||
if d1 ~= '' then
|
||||
if d2 ~= '' then
|
||||
if d1:lower() == d2:lower() then
|
||||
@@ -558,6 +552,8 @@ function os.path.join(path1, path2)
|
||||
return path2
|
||||
end
|
||||
end
|
||||
elseif d2 ~= '' then
|
||||
return path2
|
||||
end
|
||||
end
|
||||
local postsep = true
|
||||
|
||||
Reference in new issue
Block a user