Incorrect test for suffix when setting custom pages domain
Summary
When adding a new custom pages domain for a project, the domain is validated to not be a subdomain of the general pages domain (gitlab.io
in the case of gitlab.com). This should only catch actual subdomains. However, this test is incorrect and also catches perfectly valid domains that simply have the suffix gitlab.io
:
Steps to reproduce
Go to any project, then to Settings
-> Pages
-> New Domain
. Configure some domain with the suffix gitlab.io
.
What is the current bug behavior?
Domains that just have the suffix gitlab.io
without being a subdomain of gitlab.io
are forbidden.
What is the expected correct behavior?
Only actual subdomains of gitlab.io
should be forbidden.
Further information
The bug was probably introduced in 8df7bcf5.
Output of checks
This bug happens on GitLab.com
Possible fixes
The incorrect check occurs here: https://gitlab.com/gitlab-org/gitlab/-/blob/11a340f241ca93d6d2d75864a2147b313e243205/app/models/pages_domain.rb#L249