Commit 0aafd6f

mokha <mokha@cisco.com>
2017-09-18 16:21:05
solve simplify path.
1 parent edc952f
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
 
   [