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

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2012-12-25 07:14:05 +0400
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2012-12-25 07:14:05 +0400
commitc8ba5c2d58b882fd7cd5342a42158bb5f810fd60 (patch)
treec1584cc5235be75b3c6ef1a3e2a46d5ff33a73c8 /lib/extracts_path.rb
parent49e73f8ac1f9b9dabc900a56e98a1cc83b40dc49 (diff)
Fix routing issues when navigating over tree, commits etc
Diffstat (limited to 'lib/extracts_path.rb')
-rw-r--r--lib/extracts_path.rb12
1 files changed, 11 insertions, 1 deletions
diff --git a/lib/extracts_path.rb b/lib/extracts_path.rb
index b60dfd036e1..220e3d2271f 100644
--- a/lib/extracts_path.rb
+++ b/lib/extracts_path.rb
@@ -33,6 +33,9 @@ module ExtractsPath
# extract_ref("v2.0.0/README.md")
# # => ['v2.0.0', 'README.md']
#
+ # extract_ref('/gitlab/vagrant/tree/master/app/models/project.rb')
+ # # => ['master', 'app/models/project.rb']
+ #
# extract_ref('issues/1234/app/models/project.rb')
# # => ['issues/1234', 'app/models/project.rb']
#
@@ -47,6 +50,13 @@ module ExtractsPath
return pair unless @project
+ # Remove project, actions and all other staff from path
+ input.gsub!("/#{@project.path_with_namespace}", "")
+ input.gsub!(/^\/(tree|commits|blame|blob)\//, "") # remove actions
+ input.gsub!(/\?.*$/, "") # remove stamps suffix
+ input.gsub!(/.atom$/, "") # remove rss feed
+ input.gsub!(/\/edit$/, "") # remove edit route part
+
if input.match(/^([[:alnum:]]{40})(.+)/)
# If the ref appears to be a SHA, we're done, just split the string
pair = $~.captures
@@ -98,7 +108,7 @@ module ExtractsPath
request.format = :atom
end
- @ref, @path = extract_ref(params[:id])
+ @ref, @path = extract_ref(request.fullpath)
@id = File.join(@ref, @path)