Skip to content

Commit

Permalink
fix: possible double slash in canonical
Browse files Browse the repository at this point in the history
  • Loading branch information
lucymtc committed Jan 19, 2024
1 parent 74f098e commit 64faccb
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions wp/headless-wp/includes/classes/Integrations/YoastSEO.php
Original file line number Diff line number Diff line change
Expand Up @@ -263,17 +263,19 @@ public function override_search_title( $title ) {
}

/**
* Yoast doesn't typically have a canonical for search and returns URL as the homepage URL. Generally https://gus.test/?s=test
* But with headstartwp nextjs app tipically there is a route for search page.
* Yoast doesn't have a canonical for search and returns URL as the homepage URL. Generally https://gus.test/?s=test
* But with headstartwp nextjs app usually there is a route for search page.
* Default is 'search'.
*
* @param string $canonical The canonical URL.
* @return string
*/
public function override_search_canonical( $canonical ) {
if ( $this->get_yoast_search_query_vars() ) {
$canonical .= apply_filters( 'tenup_headless_wp_search_route', 'search' );
$search_route = apply_filters( 'tenup_headless_wp_search_route', 'search' );
$canonical = rtrim( $canonical, '/' ) . '/' . $search_route;
}

return $canonical;
}
}

0 comments on commit 64faccb

Please sign in to comment.