mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-06-28 22:30:04 +00:00
HTTP API: Remove empty ? when only anchor remains in add_query_arg().
If after processing through `add_query_arg()` a `?#` remains, this commit removes the unnecessary and unused `?` character as there are no query args in the URL. Includes tests. Follow-up to [1823], [5193], [5999], [6005]. Props benjaminanakenam, sabernhardt, costdev, hellofromTonya. Fixes #44499. git-svn-id: https://develop.svn.wordpress.org/trunk@52187 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -1169,6 +1169,7 @@ function add_query_arg( ...$args ) {
|
||||
$ret = preg_replace( '#=(&|$)#', '$1', $ret );
|
||||
$ret = $protocol . $base . $ret . $frag;
|
||||
$ret = rtrim( $ret, '?' );
|
||||
$ret = str_replace( '?#', '#', $ret );
|
||||
return $ret;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user