Changeset 48166
- Timestamp:
- 06/25/2020 11:39:23 AM (4 years ago)
- Location:
- trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/canonical.php
r48153 r48166 58 58 } 59 59 60 if ( is_admin() || is_search() || is_preview() || is_trackback() 61 || is_favicon() ||( $is_IIS && ! iis7_supports_permalinks() )60 if ( is_admin() || is_search() || is_preview() || is_trackback() || is_favicon() 61 || ( $is_IIS && ! iis7_supports_permalinks() ) 62 62 ) { 63 63 return; … … 656 656 } 657 657 658 // Remove trailing slash for sitemaps requests. 659 if ( ! empty( get_query_var( 'sitemap' ) ) || ! empty( get_query_var( 'sitemap-stylesheet' ) ) ) { 658 // Remove trailing slash for robots.txt or sitemap requests. 659 if ( is_robots() 660 || ! empty( get_query_var( 'sitemap' ) ) || ! empty( get_query_var( 'sitemap-stylesheet' ) ) 661 ) { 660 662 $redirect['path'] = untrailingslashit( $redirect['path'] ); 661 663 } … … 681 683 ) { 682 684 $redirect['host'] = $original['host']; 683 }684 685 // Even if the permalink structure ends with a slash, remove slash robots.txt.686 if ( is_robots() ) {687 $redirect['path'] = untrailingslashit( $redirect['path'] );688 685 } 689 686 -
trunk/tests/phpunit/tests/canonical/robots.php
r48155 r48166 8 8 class Tests_Canonical_Robots extends WP_Canonical_UnitTestCase { 9 9 10 function setUp() { 11 parent::setUp(); 12 } 13 14 function test_robots_url() { 15 $this->set_permalink_structure( '/%year%/%monthnum%/%day%/%postname%/' ); 10 public function test_remove_trailing_slashes_for_robots_requests() { 11 $this->set_permalink_structure( '/%postname%/' ); 16 12 $this->assertCanonical( '/robots.txt', '/robots.txt' ); 17 13 $this->assertCanonical( '/robots.txt/', '/robots.txt' ); -
trunk/tests/phpunit/tests/canonical/sitemaps.php
r48072 r48166 8 8 */ 9 9 class Tests_Canonical_Sitemaps extends WP_Canonical_UnitTestCase { 10 10 11 public function setUp() { 11 12 parent::setUp(); … … 39 40 $this->assertCanonical( '/wp-sitemap.xsl/', '/wp-sitemap.xsl' ); 40 41 } 42 41 43 }
Note: See TracChangeset
for help on using the changeset viewer.