Commit 0aafd6f
Changed files (1)
spec
heaps_stacks_queues
spec/heaps_stacks_queues/simplify_path_spec.rb
@@ -35,7 +35,18 @@ DOC
describe "simplify_path" do
def simplify_path(path)
- path
+ result = []
+ path.split('/').each do |part|
+ case part
+ when '.'
+ when '..'
+ result.pop
+ when ''
+ else
+ result.push(part)
+ end
+ end
+ "/" + result.join('/')
end
[