Catch more blank query string thing cases, without resorting to crazy regex. props filosofo. fixes #8098

git-svn-id: http://svn.automattic.com/wordpress/trunk@9645 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
markjaquith 2008-11-12 21:08:48 +00:00
parent e85e3bb203
commit 7ab338d7f8
1 changed files with 1 additions and 1 deletions

View File

@ -204,7 +204,7 @@ function redirect_canonical($requested_url=null, $do_redirect=true) {
$redirect['query'] = preg_replace( '#((p|page_id|cat|tag)=[^&]*?)(%20| )+$#', '$1', $redirect['query'] ); $redirect['query'] = preg_replace( '#((p|page_id|cat|tag)=[^&]*?)(%20| )+$#', '$1', $redirect['query'] );
// Clean up empty query strings // Clean up empty query strings
$redirect['query'] = preg_replace( '#(^\??|&)(p|page_id|cat|tag)=?$#', '', $redirect['query'] ); $redirect['query'] = trim(preg_replace( '#(^|&)(p|page_id|cat|tag)=?(&|$)#', '&', $redirect['query']), '&');
// Remove redundant leading ampersands // Remove redundant leading ampersands
$redirect['query'] = preg_replace( '#^\??&+#', '', $redirect['query'] ); $redirect['query'] = preg_replace( '#^\??&+#', '', $redirect['query'] );