WordPress.org

Make WordPress Core

Opened 3 years ago

Last modified 4 months ago

#44499 accepted defect (bug)

add_query_arg function doesn't remove the empty '?' when an anchor exists

Reported by: benjamin.anakena Owned by: sabernhardt
Milestone: 5.9 Priority: normal
Severity: minor Version: 4.9.6
Component: General Keywords: has-patch needs-testing
Focuses: Cc:

Description

To reproduce:

<?php
$url = 'https://domain.com/uri?param=value#anchor';
$url = add_query_arg( 'param', false, $url );
echo $url;

Expected value: https://domain.com/uri#anchor
Returned value: https://domain.com/uri?#anchor

Attachments (1)

44499.patch (414 bytes) - added by sabernhardt 12 months ago.
replace ?# with #

Download all attachments as: .zip

Change History (4)

@sabernhardt
12 months ago

replace ?# with #

#1 @sabernhardt
12 months ago

  • Keywords has-patch needs-testing added

@benjaminanakena Thanks for the report!

44499.patch works with the example.

#2 @sabernhardt
8 months ago

#52503 was marked as a duplicate.

#3 @sabernhardt
4 months ago

  • Milestone changed from Awaiting Review to 5.9
  • Owner set to sabernhardt
  • Status changed from new to accepted
Note: See TracTickets for help on using tickets.