-
Notifications
You must be signed in to change notification settings - Fork 243
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(path) return original casing instead of normalized
Use normalizing only for matching. Use original casing when applying. This problem only existed on Windows. Impacted functions: - path.common_prefix: no longer forces results to lowercase - path.relpath: no longer forces results to lowercase - dir.copyfile: no longer creates files in forced lowercase - dir.movefile: no longer moves files as forced lowercase - dir.makepath: no longer creates directories as forced lowercase
- Loading branch information
Showing
6 changed files
with
131 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,39 @@ | ||
local path = require 'pl.path' | ||
local test = require 'pl.test' | ||
|
||
relpath = path.relpath | ||
|
||
path = '/a/b/c' | ||
local asserteq = test.asserteq | ||
|
||
function slash (p) | ||
return (p:gsub('\\','/')) | ||
end | ||
|
||
|
||
-- path.relpath | ||
|
||
|
||
local testpath = '/a/B/c' | ||
|
||
function try (p,r) | ||
test.asserteq(slash(relpath(p,path)),r) | ||
asserteq(slash(path.relpath(p,testpath)),r) | ||
end | ||
|
||
try('/a/b/c/one.lua','one.lua') | ||
try('/a/b/c/bonzo/two.lua','bonzo/two.lua') | ||
try('/a/b/three.lua','../three.lua') | ||
try('/a/B/c/one.lua','one.lua') | ||
try('/a/B/c/bonZO/two.lua','bonZO/two.lua') | ||
try('/a/B/three.lua','../three.lua') | ||
try('/a/four.lua','../../four.lua') | ||
try('one.lua','one.lua') | ||
try('../two.lua','../two.lua') | ||
|
||
|
||
-- path.common_prefix | ||
|
||
|
||
asserteq(slash(path.common_prefix("../anything","../anything/goes")),"../anything") | ||
asserteq(slash(path.common_prefix("../anything/goes","../anything")),"../anything") | ||
asserteq(slash(path.common_prefix("../anything/goes","../anything/goes")),"../anything") | ||
asserteq(slash(path.common_prefix("../anything/","../anything/")),"../anything") | ||
asserteq(slash(path.common_prefix("../anything","../anything")),"..") | ||
asserteq(slash(path.common_prefix("/hello/world","/hello/world/filename.doc")),"/hello/world") | ||
asserteq(slash(path.common_prefix("/hello/filename.doc","/hello/filename.doc")),"/hello") | ||
if path.is_windows then | ||
asserteq(path.common_prefix("c:\\hey\\there","c:\\hey"),"c:\\hey") | ||
end |