Skip to content

Commit

Permalink
Use the REQUEST_URI instead of the request as interpreted by WordPres…
Browse files Browse the repository at this point in the history
…s so we can ensure to persist the trailing slash if it's there

Closes #14
  • Loading branch information
danielbachhuber committed Oct 9, 2012
1 parent 80c91b0 commit 0f029b7
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions safe-redirect-manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -663,14 +663,13 @@ public function update_redirect_cache() {
* Check current url against redirects
*
* @since 1.0
* @param object $current_request
* @uses esc_url_raw, wp_safe_redirect, untrailingslashit, get_transient, add_filter
* @return void
*/
public function action_parse_request( $current_request ) {
public function action_parse_request() {

// get requested path and add a / before it
$requested_path = '/' . ltrim( trim( $current_request->request ), '/' );
// get requested path and add a / before it
$requested_path = sanitize_text_field( $_SERVER['REQUEST_URI'] );

// get redirects from cache or recreate it
if ( false === ( $redirects = get_transient( $this->cache_key_redirects ) ) ) {
Expand All @@ -692,7 +691,7 @@ public function action_parse_request( $current_request ) {
}

// check if requested path is the same as the redirect from path
$matched_path = ( $requested_path == $redirect_from );
$matched_path = ( untrailingslashit( $requested_path ) == $redirect_from );

// check if the redirect_from ends in a wildcard
if ( !$matched_path && (strrpos( $redirect_from, '*' ) == strlen( $redirect_from ) - 1) ) {
Expand Down

0 comments on commit 0f029b7

Please sign in to comment.