This instance will be upgraded to Heptapod 0.31.0 (final) on 2022-05-24 at 14:00 UTC+2 (a few minutes of down time)

Commit 12735eef authored by Bob Van Landuyt's avatar Bob Van Landuyt
Browse files

Minor style adjustments

parent 33b16faecc3d
......@@ -16,20 +16,33 @@ class DynamicPathValidator < ActiveModel::EachValidator
# the path `api` shouldn't be allowed because it would be masked by `api/*`
#
TOP_LEVEL_ROUTES = Set.new(%w[
-
.well-known
abuse_reports
admin
all
api
assets
autocomplete
ci
dashboard
explore
files
groups
health_check
help
hooks
import
invites
issues
jwt
koding
member
merge_requests
new
notes
notification_settings
oauth
profile
projects
public
......@@ -37,29 +50,14 @@ class DynamicPathValidator < ActiveModel::EachValidator
robots.txt
s
search
sent_notifications
services
snippets
teams
u
unsubscribes
users
api
autocomplete
search
member
explore
uploads
import
notification_settings
abuse_reports
invites
help
koding
health_check
jwt
oauth
sent_notifications
-
users
]).freeze
# All project routes with wildcard argument must be listed here.
......@@ -71,10 +69,30 @@ class DynamicPathValidator < ActiveModel::EachValidator
# without tree as reserved name routing can match 'group/project' as group name,
# 'tree' as project name and 'deploy_keys' as route.
#
WILDCARD_ROUTES = Set.new(%w[tree commits wikis new edit create update logs_tree
preview blob blame raw files create_dir find_file
artifacts graphs refs badges info/lfs/objects
gitlab-lfs/objects environments/folders])
WILDCARD_ROUTES = Set.new(%w[
artifacts
badges
blame
blob
commits
create
create_dir
edit
environments/folders
files
find_file
gitlab-lfs/objects
graphs
info/lfs/objects
logs_tree
new
preview
raw
refs
tree
update
wikis
]).freeze
STRICT_RESERVED = (TOP_LEVEL_ROUTES | WILDCARD_ROUTES).freeze
......
......@@ -4,9 +4,7 @@ def matches?(request)
project_path = request.params[:project_id] || request.params[:id]
full_path = namespace_path + '/' + project_path
unless DynamicPathValidator.valid?(full_path)
return false
end
return false unless DynamicPathValidator.valid?(full_path)
Project.find_by_full_path(full_path).present?
end
......
......@@ -11,13 +11,14 @@ def rename_namespaces(type:)
end
def namespaces_for_paths(type:)
namespaces = if type == :wildcard
namespaces = case type
when :wildcard
MigrationClasses::Namespace.where.not(parent_id: nil)
elsif type == :top_level
when :top_level
MigrationClasses::Namespace.where(parent_id: nil)
end
with_paths = MigrationClasses::Route.arel_table[:path].
matches_any(path_patterns)
matches_any(path_patterns)
namespaces.joins(:route).where(with_paths)
end
......
......@@ -8,7 +8,7 @@ class Router
# regex itself)
# - Ending in `noteable/issue/<id>/notes` for the `issue_notes` route
# - Ending in `issues/id`/rendered_title` for the `issue_title` route
USED_IN_ROUTES = %w[noteable issue notes issues renderred_title
USED_IN_ROUTES = %w[noteable issue notes issues rendered_title
commit pipelines merge_requests new].freeze
RESERVED_WORDS = DynamicPathValidator::WILDCARD_ROUTES - USED_IN_ROUTES
RESERVED_WORDS_REGEX = Regexp.union(*RESERVED_WORDS)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment