Skip to content

Commit

Permalink
Merge pull request #6727 from ampproject/fix/wp59-phpunit-tests
Browse files Browse the repository at this point in the history
Fix `test_amp_remove_paired_endpoint` in WP 5.9 by removing empty query string
  • Loading branch information
westonruter authored Nov 17, 2021
2 parents 9069888 + fb82dcc commit 094aef8
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 3 additions & 1 deletion src/PairedUrl.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ final class PairedUrl implements Service {
* @return string URL.
*/
public function remove_query_var( $url ) {
return remove_query_arg( amp_get_slug(), $url );
$url = remove_query_arg( amp_get_slug(), $url );
$url = str_replace( '?#', '#', $url ); // See <https://core.trac.wordpress.org/ticket/44499>.
return $url;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion tests/php/test-amp-helper-functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -654,7 +654,7 @@ public function test_amp_remove_paired_endpoint() {
$this->assertEquals( 'https://example.com/foo/', amp_remove_paired_endpoint( 'https://example.com/foo/?amp' ) );
$this->assertEquals( 'https://example.com/foo/', amp_remove_paired_endpoint( 'https://example.com/foo/?amp=1' ) );
$this->assertEquals( 'https://example.com/foo/', amp_remove_paired_endpoint( 'https://example.com/foo/amp/?amp=1' ) );
$this->assertEquals( 'https://example.com/foo/?#bar', amp_remove_paired_endpoint( 'https://example.com/foo/?amp#bar' ) );
$this->assertEquals( 'https://example.com/foo/#bar', amp_remove_paired_endpoint( 'https://example.com/foo/?amp#bar' ) );
$this->assertEquals( 'https://example.com/foo/', amp_remove_paired_endpoint( 'https://example.com/foo/amp/' ) );
$this->assertEquals( 'https://example.com/foo/?blaz', amp_remove_paired_endpoint( 'https://example.com/foo/amp/?blaz' ) );
}
Expand Down

0 comments on commit 094aef8

Please sign in to comment.