diff --git a/output/html/http.php b/output/html/http.php index 8da2990a..38d921db 100644 --- a/output/html/http.php +++ b/output/html/http.php @@ -113,8 +113,22 @@ public function output() { $css = 'qm-warn'; } - $url = self::format_url( $row['url'] ); - $info = ''; + $url = self::format_url( $row['url'] ); + $query = parse_url( $row['url'], PHP_URL_QUERY ); + $query_output = ''; + $info = ''; + + if ( ! empty( $query ) ) { + $query = '?' . $query; + $url = str_replace( $query, '', $row['url'] ); + $url = self::format_url( $url ); + + $query_output = sprintf( + '%s', + self::build_toggler(), + str_replace( array( '?', '&' ), array( '?', '
  • &' ), esc_html( $query ) ) + ); + } $url = preg_replace( '|^http:|', 'http:', $url ); @@ -165,19 +179,34 @@ public function output() { ); if ( ! empty( $row['redirected_to'] ) ) { + $query = parse_url( $row['redirected_to'], PHP_URL_QUERY ); + $redirected_to = $row['redirected_to']; + + if ( ! empty( $query ) ) { + $redirected_to = str_replace( '?' . $query, '', $redirected_to ); + } + $url .= sprintf( '
    %1$s%2$s
    %3$s', QueryMonitor::icon( 'warning' ), /* translators: An HTTP API request redirected to another URL */ __( 'Redirected to:', 'query-monitor' ), - self::format_url( $row['redirected_to'] ) + self::format_url( $redirected_to ) ); } + $classes = 'qm-url qm-ltr qm-wrap'; + + if ( ! empty( $query_output ) ) { + $classes .= ' qm-has-toggle'; + } + printf( // WPCS: XSS ok. - '%s%s', + '%s%s%s', + $classes, $info, - $url + $url, + $query_output ); $show_toggle = ! empty( $row['info'] );