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. Built from https://develop.svn.wordpress.org/trunk@52187 git-svn-id: http://core.svn.wordpress.org/trunk@51779 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
33499dc6d8
commit
ec522e3f98
|
@ -1169,6 +1169,7 @@ function add_query_arg( ...$args ) {
|
||||||
$ret = preg_replace( '#=(&|$)#', '$1', $ret );
|
$ret = preg_replace( '#=(&|$)#', '$1', $ret );
|
||||||
$ret = $protocol . $base . $ret . $frag;
|
$ret = $protocol . $base . $ret . $frag;
|
||||||
$ret = rtrim( $ret, '?' );
|
$ret = rtrim( $ret, '?' );
|
||||||
|
$ret = str_replace( '?#', '#', $ret );
|
||||||
return $ret;
|
return $ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
*
|
*
|
||||||
* @global string $wp_version
|
* @global string $wp_version
|
||||||
*/
|
*/
|
||||||
$wp_version = '5.9-alpha-52186';
|
$wp_version = '5.9-alpha-52187';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||||
|
|
Loading…
Reference in New Issue