putyourlightson / craft-blitz

Intelligent static page caching for creating lightning-fast sites with Craft CMS.
https://putyourlightson.com/plugins/blitz
Other
147 stars 35 forks source link

Incorrect handling of /intl prefix in URLs results in site URI construction error #659

Closed tshlos closed 1 month ago

tshlos commented 2 months ago

Bug Report

When attempting to construct site URIs from URLs containing the /intl prefix, the current implementation of the getSiteUriFromUrl() function in the codebase fails to properly account for this prefix. As a result, the /intl part of the URL is being removed during the construction of the SiteUriModel, leading to incorrect site URIs.

Steps to Reproduce:

  1. Provide a URL containing the /intl prefix, such as https://example.com/intl/page.
  2. Call the getSiteUriFromUrl() function with the provided URL.
  3. Observe that the resulting SiteUriModel does not include the /intl prefix in the URI.

Expected Behavior:

The getSiteUriFromUrl() function should correctly handle URLs with the /intl prefix and include this prefix in the constructed SiteUriModel.

Actual Behavior:

The /intl part of the URL is being removed during the construction of the SiteUriModel, resulting in incorrect site URIs.

Plugin Version

4.9.3

Craft CMS Version

4.5.12

PHP Version

8.3.4

bencroker commented 2 months ago

The getSiteUriFromUrl() function should correctly handle URLs with the /intl prefix and include this prefix in the constructed SiteUriModel.

How are you verifying that this is not the case?

Note the the uri property of the SiteUriModel class is the URI that follows the base site URL of the site as defined by the siteId property, meaning that if the site’s base URL is https://example.com/intl/, the expected value of uri is page.

tshlos commented 1 month ago

Apologies for the delay in responding. Upon reviewing your clarification, I realize there was a misunderstanding on my part regarding the functionality of the SiteUriModel class. Thanks for clearing that up. Appreciate your assistance.

bencroker commented 1 month ago

Ok, sure thing!