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



9
10
11
12
13
14
15
16
# File 'lib/gitlab/git/path_helper.rb', line 9

def normalize_path(filename)
  # Strip all leading slashes so that //foo -> foo
  filename = filename.sub(%r{\A/*}, '')

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