fix(bug): GitLab Pages case-sensitivity redirect loops

What does this MR do?

This MR fixes #526293 an issue where Lowercase Pages URLs of mixed case Project slug, causing redirect loops when 'Use unique domain' is disabled

Root Cause

When a project has a mixed-case slug (e.g., "MR-1510"):

  1. Cookie Path: Set based on the user's request URI (lowercase: /mr-1510/)
  2. Redirect URI: Generated from the database's canonical path (uppercase: /MR-1510/)
  3. Result: Browser won't send cookies because paths don't match (case-sensitive) → infinite redirect loop

Solution

Normalize the path prefix to lowercase in two locations:

  1. Pages::LookupPath#ensure_leading_and_trailing_slash: The prefix attribute sent to the GitLab Pages daemon is now lowercased. This ensures Pages
    uses lowercase paths for both cookie paths and redirect URIs, maintaining consistency.
  2. Gitlab::Pages::UrlBuilder#project_path_segment: The project path in generated URLs is now lowercased. This ensures URLs displayed in the GitLab UI match the actual URLs served by Pages.

Test

Updated Tests - Added test cases for mixed-case scenarios:
spec/models/pages/lookup_path_spec.rb - Added tests for 'MyGroup/MR-1510' paths
spec/lib/gitlab/pages/url_builder_spec.rb - Added test for 'group/MR-1510' scenario

Edited by Rishi Prasad Sulakhe

Merge request reports

Loading
Loading