From b7d0c525223e2f1c3791be50d8025425caa44f37 Mon Sep 17 00:00:00 2001 From: Paulo Pinto Date: Mon, 12 Sep 2022 16:28:38 +0100 Subject: [PATCH] Make phpcs happy --- src/Http/Router.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Http/Router.php b/src/Http/Router.php index 6c5eccd..1667ec3 100644 --- a/src/Http/Router.php +++ b/src/Http/Router.php @@ -56,14 +56,14 @@ function () use ( $route, $methods ) { ); } - private function get_current_route() { + private function get_current_route(): string { $wp_url = get_site_url(); - $installed_dir = parse_url( $wp_url, PHP_URL_PATH ); + $installed_dir = wp_parse_url( $wp_url, PHP_URL_PATH ); - // requested uri relative to WP install - $request_uri = str_replace( $installed_dir, '', $_SERVER['REQUEST_URI'] ); + // Requested URI relative to WP install. + $uri = isset( $_SERVER['REQUEST_URI'] ) ? esc_url_raw( wp_unslash( $_SERVER['REQUEST_URI'] ) ) : ''; + $uri = str_replace( $installed_dir, '', $uri ); - $uri = sanitize_text_field( wp_unslash( $request_uri ) ); $route = strtok( $uri, '?' ); return trim( $route, '/' );