Skip to content

Commit

Permalink
Social Links: Don't prepend URL fragments
Browse files Browse the repository at this point in the history
  • Loading branch information
Mamaduka committed Jan 14, 2025
1 parent 669662c commit 7d7c7f4
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions packages/block-library/src/social-link/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down

0 comments on commit 7d7c7f4

Please sign in to comment.