diff --git a/README.md b/README.md index 0367205..fddfb65 100644 --- a/README.md +++ b/README.md @@ -7,6 +7,9 @@ The code on this repository has to match the WordPress Coding Standards in order Every pull request will be checked against WPCS through GitHub Actions. ## Version History +### 2.1.1 +* Bugfix - Ignore trailing slash in public url (prevents potential double slash when filtering first path parameter) + ### 2.1.0 * Added - Ignore Path Segments setting to remove specific path segments when building public URLs * Enhanced - Public URL functionality to handle complex URL transformations diff --git a/siteimprove/admin/class-siteimprove-admin.php b/siteimprove/admin/class-siteimprove-admin.php index 4221ca0..ed6237e 100755 --- a/siteimprove/admin/class-siteimprove-admin.php +++ b/siteimprove/admin/class-siteimprove-admin.php @@ -284,7 +284,10 @@ private function siteimprove_add_js( $url, $type ) { // Apply public URL transformation if configured. if ( ! empty( $public_url ) ) { - $url = "$public_url$path" . ( isset( $parsed_url['query'] ) ? "?$parsed_url[query]" : '' ); + $public_url = rtrim( $public_url, '/' ); + $normalized_path = '/' . ltrim( $path, '/' ); + $query_string = isset( $parsed_url['query'] ) ? '?' . $parsed_url['query'] : ''; + $url = $public_url . $normalized_path . $query_string; } else { // If no public URL is set, reconstruct the URL with the filtered path. $scheme = isset( $parsed_url['scheme'] ) ? $parsed_url['scheme'] . '://' : ''; diff --git a/siteimprove/readme.txt b/siteimprove/readme.txt index ff5504c..a575c19 100644 --- a/siteimprove/readme.txt +++ b/siteimprove/readme.txt @@ -87,6 +87,9 @@ Please review whether you have JavaScript turned off in your browser. We use Jav == Changelog == += 2.1.1 = +* Bugfix - Ignore trailing slash in public url (prevents potential double slash when filtering first path parameter) + = 2.1.0 = * Added - Ignore Path Segments setting to remove specific path segments when building public URLs * Enhanced - Public URL functionality to handle complex URL transformations