Skip to content

Commit

Permalink
Fix EZP-24141: Double slash in url after having searched a default lo…
Browse files Browse the repository at this point in the history
…cation for an object relation in class edit module

If there are any unordered parameters, remove trailing slash(es) before adding the parameters, to avoid double slash.
  • Loading branch information
glye committed Mar 30, 2015
1 parent 3882dd3 commit 895f414
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lib/ezutils/classes/ezmodule.php
Expand Up @@ -857,14 +857,17 @@ function redirectionURIForModule( $module, $viewName, $parameters = array(),
$uri .= $unorderedURI;
}

if ( is_array( $userParameters ) )
if ( !empty( $userParameters ) && is_array( $userParameters ) )
{
// Remove any slash(es) at the end of the uri, because the user params are appended with a leading slash
$uri = preg_replace( "#(^.*)(/+)$#", "\$1", $uri );
foreach ( $userParameters as $name => $value )
{
$uri .= '/(' . $name . ')/' . $value;
}
}

// Remove multiple slashes at the end of the uri
$uri = preg_replace( "#(^.*)(//+)$#", "\$1", $uri );
if ( $anchor !== false )
$uri .= '#' . urlencode( $anchor );
Expand Down

0 comments on commit 895f414

Please sign in to comment.