From 18cc457414a02462186be6acb034356939e834ab Mon Sep 17 00:00:00 2001 From: Adnan Haque <3737780+haqadn@users.noreply.github.com> Date: Fri, 22 Nov 2024 16:32:38 +0600 Subject: [PATCH] Boost: Create hash from URL without trailing slash (#40303) * Create hash from URL without trailing slash * changelog * Remove leading slash from URL hash --- .../source-providers/providers/Cornerstone_Provider.php | 3 +++ .../plugins/boost/changelog/fix-cornerstone-ccss-serving | 5 +++++ 2 files changed, 8 insertions(+) create mode 100644 projects/plugins/boost/changelog/fix-cornerstone-ccss-serving diff --git a/projects/plugins/boost/app/lib/critical-css/source-providers/providers/Cornerstone_Provider.php b/projects/plugins/boost/app/lib/critical-css/source-providers/providers/Cornerstone_Provider.php index 5c1f71541cdf8..157b2e014a7d7 100644 --- a/projects/plugins/boost/app/lib/critical-css/source-providers/providers/Cornerstone_Provider.php +++ b/projects/plugins/boost/app/lib/critical-css/source-providers/providers/Cornerstone_Provider.php @@ -83,6 +83,9 @@ public static function get_hash_for_url( $url ) { $url = substr( $url, strlen( $home_url ) ); } + $url = ltrim( $url, '/' ); + $url = untrailingslashit( $url ); + $hash = hash( 'md5', $url ); return substr( $hash, 0, 8 ); diff --git a/projects/plugins/boost/changelog/fix-cornerstone-ccss-serving b/projects/plugins/boost/changelog/fix-cornerstone-ccss-serving new file mode 100644 index 0000000000000..c60a963d2db90 --- /dev/null +++ b/projects/plugins/boost/changelog/fix-cornerstone-ccss-serving @@ -0,0 +1,5 @@ +Significance: patch +Type: fixed +Comment: Fixed cornerstone specific critical CSS not serving in some cases + +