Skip to content

Commit

Permalink
Fix purging subdomain URLs
Browse files Browse the repository at this point in the history
  • Loading branch information
bencroker committed Dec 4, 2024
1 parent 4c8dc63 commit c62211e
Show file tree
Hide file tree
Showing 5 changed files with 219 additions and 233 deletions.
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
# Release Notes for Cloudflare

## 3.0.2 - Unreleased
## 3.0.2 - 2024-12-04

### Changed

- Element URLs are now checked for null values for better compatibility with other plugins.

### Fixed

- Fixed a bug in which URLs with a subdomain were not being purged ([#74](https://github.com/putyourlightson/craft-cloudflare/issues/74)).

## 3.0.1 - 2024-06-18

### Changed
Expand Down
2 changes: 1 addition & 1 deletion src/controllers/RulesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public function actionSave(): Response
{
Cloudflare::$plugin->rules->saveRules();

Craft::$app->getSession()->setNotice(Craft::t(
Craft::$app->getSession()->setSuccess(Craft::t(
'cloudflare',
'Cloudflare rules saved.'
));
Expand Down
5 changes: 2 additions & 3 deletions src/helpers/UrlHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,17 +68,16 @@ public static function isPurgeableUrl(string $url, bool $includeZoneCheck): bool
*/
if ($includeZoneCheck) {
if (!$urlDomain = parse_url($url, PHP_URL_HOST)) {
// bail if we couldn't even get a base domain
return false;
}

if (strtolower($urlDomain) !== strtolower($cfDomainName)) {
if (!str_ends_with(strtolower($urlDomain), strtolower($cfDomainName))) {
Craft::info(
sprintf('Ignoring URL outside zone: %s', $url),
'cloudflare'
);

return false; // base domain doesn't match Cloudflare zone
return false;
}
}

Expand Down
Loading

0 comments on commit c62211e

Please sign in to comment.