Skip to content

Commit

Permalink
Social Links: Don't prepend URL fragments (WordPress#68655)
Browse files Browse the repository at this point in the history
Co-authored-by: Mamaduka <[email protected]>
Co-authored-by: t-hamano <[email protected]>
  • Loading branch information
3 people authored Jan 15, 2025
1 parent 7b6e775 commit 8ba15b1
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 8ba15b1

Please sign in to comment.