Class: Gitlab::Git::PathHelper

Inherits:
Object
  • Object
show all
Defined in:
lib/gitlab_git/path_helper.rb

Class Method Summary collapse

Class Method Details

.normalize_path(filename) ⇒ Object



5
6
7
8
9
10
11
12
# File 'lib/gitlab_git/path_helper.rb', line 5

def normalize_path(filename)
  # Strip all leading slashes so that //foo -> foo
  filename[/^\/*/] = ''

  # Expand relative paths (e.g. foo/../bar)
  filename = Pathname.new(filename)
  filename.relative_path_from(Pathname.new(''))
end