summaryrefslogtreecommitdiff
path: root/lib/constraints/constrainer_helper.rb
blob: ab07a6793d90d5b3a6b8067a46b8b8d80a7972f1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
module ConstrainerHelper
  def extract_resource_path(path)
    id = path.dup
    id.sub!(/\A#{relative_url_root}/, '') if relative_url_root
    id.sub(/\A\/+/, '').sub(/\/+\z/, '').sub(/.atom\z/, '')
  end

  private

  def relative_url_root
    if defined?(Gitlab::Application.config.relative_url_root)
      Gitlab::Application.config.relative_url_root
    end
  end
end