Skip to content

Commit

Permalink
Merge pull request #480 from therealpecus/v4-dev
Browse files Browse the repository at this point in the history
fix: regression on multisite canonical URLs (v4)
  • Loading branch information
Tam authored Oct 9, 2024
2 parents c31a157 + 8149588 commit fc00aac
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/models/data/SeoData.php
Original file line number Diff line number Diff line change
Expand Up @@ -377,8 +377,13 @@ public function getExpiry ()
*/
public function getCanonical ()
{
if (empty($this->advanced['canonical']))
return UrlHelper::siteUrl(Craft::$app->request->getFullPath());
if (empty($this->advanced['canonical'])) {
$fullPathWithPagination = Craft::$app->request->getFullPath();
$pathInfo = Craft::$app->request->getPathInfo();
return ($subPath = strpos($fullPathWithPagination, $pathInfo . '/')) === false ?
UrlHelper::siteUrl($pathInfo) :
UrlHelper::siteUrl(substr($fullPathWithPagination, $subPath));
}

return UrlHelper::siteUrl($this->advanced['canonical']);
}
Expand Down

0 comments on commit fc00aac

Please sign in to comment.