new function: untrailingslashit(). fixes #3899

git-svn-id: https://develop.svn.wordpress.org/trunk@5020 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Mark Jaquith 2007-03-10 06:25:33 +00:00
parent e2f9950018
commit e643142a5e
2 changed files with 6 additions and 3 deletions

View File

@ -563,12 +563,15 @@ function backslashit($string) {
}
function trailingslashit($string) {
if ( '/' != substr($string, -1)) {
if ( '/' != substr($string, -1))
$string .= '/';
}
return $string;
}
function untrailingslashit($string) {
return preg_replace('|/+$|', '', $string);
}
function addslashes_gpc($gpc) {
global $wpdb;

View File

@ -24,7 +24,7 @@ function user_trailingslashit($string, $type_of_url = '') {
if ( $wp_rewrite->use_trailing_slashes )
$string = trailingslashit($string);
else
$string = preg_replace('|/+$|', '', $string); // untrailing slash
$string = untrailingslashit($string);
// Note that $type_of_url can be one of following:
// single, single_trackback, single_feed, single_paged, feed, category, page, year, month, day, paged