nystudio107 / craft-seomatic

SEOmatic facilitates modern SEO best practices & implementation for Craft CMS 3. It is a turnkey SEO system that is comprehensive, powerful, and flexible.
https://nystudio107.com/plugins/seomatic
Other
166 stars 71 forks source link

Code meant to strip overlap, strips too much of the absolute url #1512

Closed euismod2336 closed 2 months ago

euismod2336 commented 2 months ago

Describe the bug

UrlHelper::mergeUrlWithPath removes too much when combining the parts back together again. Depending on your siteUrl it might strip different things. The TLD of your siteUrl is stripped of the beginning of the path. Related to https://github.com/nystudio107/craft-seomatic/issues/1376 This seems to only happen on the beginning of the path.

I thought about creating a PR but given there are several working solutions in the challenge, the point seemed moot :wink: https://www.craftcodingchallenge.com/challenge-14-testing-santas-patience/

To reproduce

Steps to reproduce the behaviour:

  1. Configure your siteUrl to end on .com
  2. Create an entry with uri that starts with commanding or modern (or just overwrite the path value in the helper function)
  3. Create sitemap via CLI

Expected behaviour

I would expect the resulting url to be [siteUrl]/commanding or [siteUrl]/modern and not [siteUrl]/manding and [siteUrl]/odern

Versions

image

khalwat commented 2 months ago

Yeah the algorithm is fine, the path and URL just needed to be normalized first.

Craft CMS 3:

You can try it now by setting your semver in your composer.json to look like this:

    "nystudio107/craft-seomatic": "dev-develop as 3.5.4”,

Then do a composer clear-cache && composer update

…..

Craft CMS 4:

You can try it now by setting your semver in your composer.json to look like this:

    "nystudio107/craft-seomatic": "dev-develop-v4 as 4.1.4”,

Then do a composer clear-cache && composer update

…..

Craft CMS 5:

You can try it now by setting your semver in your composer.json to look like this:

    "nystudio107/craft-seomatic": "dev-develop-v5 as 5.1.4”,

Then do a composer clear-cache && composer update