kylef / PathKit

Effortless path operations in Swift

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Combining two pathes including step back lead to incorrect path

Antondomashnev opened this issue · comments

commented

The core of the question is in Sourcery issue.

Example input:

p1 = Path(".")
p2 = Path("./../Foo")
p3 = p1 + p2

Expected output:

print(p3) -> "./../Foo"

Actual output:

print(p3) -> "./Foo"

I may be wrong in assumption, but I've tested in ruby with pathname and the + works as expected:

2.3.3 :001 > require 'pathname'
 => true 
2.3.3 :002 > p1 = Pathname.new(".")
 => #<Pathname:.> 
2.3.3 :003 > p2 = Pathname.new("./../ios-guest")
 => #<Pathname:./../ios-guest> 
2.3.3 :004 > p1.realpath
 => #<Pathname:/Users/antondomashnev/Work/Sourcery> 
2.3.3 :005 > p2.realpath
 => #<Pathname:/Users/antondomashnev/Work/ios-guest> 
2.3.3 :006 > p3 = p1 + p2
 => #<Pathname:../ios-guest> 
2.3.3 :007 > p3.realpath
 => #<Pathname:/Users/antondomashnev/Work/ios-guest> 
2.3.3 :008 >