-
Notifications
You must be signed in to change notification settings - Fork 12
Description
Description
Redirects to the Homepage are generated with a double slash.
When creating a BarrelStrength\Sprout\redirects\components\elements\RedirectElement
, RedirectHelper::findUrl()
sets newUrl to '/' on line 146.
Then, when building the redirect URL, Call to RedirectElement::getAbsoluteNewUrl()
will concatenate $baseUrl . $this->newUrl
where $baseUrl
will always already have a trailing slash.
$baseUrl is set with $baseUrl = Craft::getAlias($this->getSite()->getBaseUrl());
In Craft 5, implementation for Site::getBaseUrl() adds a trailing slash.
https://github.com/craftcms/cms/blob/0009105ffef21582c8474c7d0d96621e82374696/src/models/Site.php#L153..L172
We should either create RedirectElement
with an empty newUrl, or check if newUrl === '/'
when redirecting.
How to reproduce
Create a Redirect with:
- Old URL:
test-redirect
- New URL: (leave empty)
- Status Code: any
- Match Strategy: Exact Match
Requests to /test-redirect
should redirect to https://my-website.com/
, but redirects to https://my-website.com//
Sprout Version
5.0.3
Craft Version
5.7.10
Database Type Version
MariaDB 10.5