From 8ba15b197b469fe40541eb1174f163c2640afe89 Mon Sep 17 00:00:00 2001 From: George Mamadashvili Date: Wed, 15 Jan 2025 09:19:41 +0400 Subject: [PATCH] Social Links: Don't prepend URL fragments (#68655) Co-authored-by: Mamaduka Co-authored-by: t-hamano --- packages/block-library/src/social-link/index.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/block-library/src/social-link/index.php b/packages/block-library/src/social-link/index.php index da28034f5a55d2..f241daff2a11a8 100644 --- a/packages/block-library/src/social-link/index.php +++ b/packages/block-library/src/social-link/index.php @@ -42,9 +42,9 @@ function render_block_core_social_link( $attributes, $content, $block ) { /** * Prepend URL with https:// if it doesn't appear to contain a scheme - * and it's not a relative link starting with //. + * and it's not a relative link or a fragment. */ - if ( ! parse_url( $url, PHP_URL_SCHEME ) && ! str_starts_with( $url, '//' ) ) { + if ( ! parse_url( $url, PHP_URL_SCHEME ) && ! str_starts_with( $url, '//' ) && ! str_starts_with( $url, '#' ) ) { $url = 'https://' . $url; }