Welcome to mirror list, hosted at ThFree Co, Russian Federation.

path_helper.rb « git « gitlab « lib - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: e3a2031eecac455bdb5eb95af3ed3adadd62063e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# frozen_string_literal: true

# Gitaly note: JV: no RPC's here.

module Gitlab
  module Git
    class PathHelper
      class << self
        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
      end
    end
  end
end