Skip to content

Commit cab4c96

Browse files
committed
Fix test_amp_remove_paired_endpoint in WP 5.9 by removing empty query string (#6727)
1 parent 28ecf13 commit cab4c96

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

src/PairedUrl.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,9 @@ final class PairedUrl implements Service {
2424
* @return string URL.
2525
*/
2626
public function remove_query_var( $url ) {
27-
return remove_query_arg( amp_get_slug(), $url );
27+
$url = remove_query_arg( amp_get_slug(), $url );
28+
$url = str_replace( '?#', '#', $url ); // See <https://core.trac.wordpress.org/ticket/44499>.
29+
return $url;
2830
}
2931

3032
/**

tests/php/test-amp-helper-functions.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -651,7 +651,7 @@ public function test_amp_remove_paired_endpoint() {
651651
$this->assertEquals( 'https://example.com/foo/', amp_remove_paired_endpoint( 'https://example.com/foo/?amp' ) );
652652
$this->assertEquals( 'https://example.com/foo/', amp_remove_paired_endpoint( 'https://example.com/foo/?amp=1' ) );
653653
$this->assertEquals( 'https://example.com/foo/', amp_remove_paired_endpoint( 'https://example.com/foo/amp/?amp=1' ) );
654-
$this->assertEquals( 'https://example.com/foo/?#bar', amp_remove_paired_endpoint( 'https://example.com/foo/?amp#bar' ) );
654+
$this->assertEquals( 'https://example.com/foo/#bar', amp_remove_paired_endpoint( 'https://example.com/foo/?amp#bar' ) );
655655
$this->assertEquals( 'https://example.com/foo/', amp_remove_paired_endpoint( 'https://example.com/foo/amp/' ) );
656656
$this->assertEquals( 'https://example.com/foo/?blaz', amp_remove_paired_endpoint( 'https://example.com/foo/amp/?blaz' ) );
657657
}

0 commit comments

Comments
 (0)