Allow for example2-style domains

This commit is contained in:
Alex Kirk 2022-12-13 11:01:17 +01:00
parent b3e71ff803
commit 6c03ab1704
2 changed files with 3 additions and 4 deletions

View file

@ -159,7 +159,6 @@ add_action(
/**
* Disable webfinger for known example domains.
*/
add_filter(
'pre_get_remote_metadata_by_actor',
function( $metadata, $actor ) {
@ -181,7 +180,7 @@ add_filter(
}
}
}
if ( strtok( $domain, '.' ) === 'example' ) {
if ( rtrim( strtok( $domain, '.' ), '0123456789' ) === 'example' ) {
$metadata = array(
'url' => sprintf( 'https://%s/users/%s/', $domain, $username ),
'name' => $username,
@ -190,6 +189,6 @@ add_filter(
}
return $metadata;
},
10,
9,
2
);

View file

@ -12,7 +12,7 @@ class Test_Functions extends ActivityPub_TestCase_Cache_HTTP {
add_filter( 'pre_http_request', array( $this, 'invalid_http_response' ), 8, 3 );
foreach ( array( 'user', 'test' ) as $username ) {
foreach ( array( 'example.org', 'example.net' ) as $domain ) {
foreach ( array( 'example.org', 'example.net', 'example2.com' ) as $domain ) {
foreach ( array( '@', '' ) as $leading_at ) {
$metadata = \ActivityPub\get_remote_metadata_by_actor( $username . '@' . $domain );
$this->assertEquals( sprintf( 'https://%s/users/%s/', $domain, $username ), $metadata['url'], $username . '@' . $domain );