From 35d79e5b571bd051db9467b1e931b72301b17654 Mon Sep 17 00:00:00 2001 From: Drew Blessing Date: Thu, 10 Jul 2025 14:39:14 -0500 Subject: [PATCH] Move organizations paths to new /o/ structure To allow the shortest possible paths, we will use `/o/` paths instead of `/-/organizations/`. This change ensures that `o` is a reserved top-level name. --- config/routes.rb | 3 ++- config/routes/organizations.rb | 12 +++++++++--- doc/user/reserved_names.md | 1 + lib/gitlab/path_regex.rb | 1 + spec/lib/gitlab/path_regex_spec.rb | 2 +- 5 files changed, 14 insertions(+), 5 deletions(-) diff --git a/config/routes.rb b/config/routes.rb index 39a441acdb6d40..de8595c54afe36 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -86,6 +86,8 @@ # Terraform service discovery get '.well-known/terraform.json' => 'terraform/services#index', as: :terraform_services + draw :organizations + # Begin of the /-/ scope. # Use this scope for all new global routes. scope path: '-' do @@ -170,7 +172,6 @@ draw :operations draw :jira_connect - draw :organizations Gitlab.ee do draw 'remote_development/resources' diff --git a/config/routes/organizations.rb b/config/routes/organizations.rb index 30e11d3473b734..a8ce00cd7149c4 100644 --- a/config/routes/organizations.rb +++ b/config/routes/organizations.rb @@ -1,10 +1,16 @@ # frozen_string_literal: true -resources(:organizations, only: [:show, :index, :new], param: :organization_path, module: :organizations) do - collection do - post :preview_markdown +# Index and new actions use /-/organizations path +scope '-' do + resources(:organizations, only: [:index, :new], module: :organizations) do + collection do + post :preview_markdown + end end +end +# All routes for a specific organization use /o/ path +resources(:organizations, path: 'o', only: [:show], param: :organization_path, module: :organizations) do member do get :activity get :groups_and_projects diff --git a/doc/user/reserved_names.md b/doc/user/reserved_names.md index b8a6fb98983ddf..299e1627afbf27 100644 --- a/doc/user/reserved_names.md +++ b/doc/user/reserved_names.md @@ -86,6 +86,7 @@ You cannot create groups with the following names, because they are reserved for - `import` - `jwt` - `login` +- `o` - `oauth` - `profile` - `projects` diff --git a/lib/gitlab/path_regex.rb b/lib/gitlab/path_regex.rb index 09bf048ce901ab..5d2ce6b2248948 100644 --- a/lib/gitlab/path_regex.rb +++ b/lib/gitlab/path_regex.rb @@ -36,6 +36,7 @@ module PathRegex import jwt login + o oauth profile projects diff --git a/spec/lib/gitlab/path_regex_spec.rb b/spec/lib/gitlab/path_regex_spec.rb index 434a2e153720a2..786f9f989789ea 100644 --- a/spec/lib/gitlab/path_regex_spec.rb +++ b/spec/lib/gitlab/path_regex_spec.rb @@ -194,7 +194,7 @@ def failure_message(constant_name, migration_helper, missing_words: [], addition # We ban new items in this list, see https://gitlab.com/gitlab-org/gitlab/-/issues/215362 it 'does not allow expansion' do - expect(described_class::TOP_LEVEL_ROUTES.size).to eq(38) + expect(described_class::TOP_LEVEL_ROUTES.size).to eq(39) end end -- GitLab