From 6c03ab17048df132d10b5e2d3e8932ec00bdaed6 Mon Sep 17 00:00:00 2001 From: Alex Kirk Date: Tue, 13 Dec 2022 11:01:17 +0100 Subject: [PATCH] Allow for example2-style domains --- activitypub.php | 5 ++--- tests/test-functions.php | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/activitypub.php b/activitypub.php index 6c77a3b..1f59055 100644 --- a/activitypub.php +++ b/activitypub.php @@ -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 ); diff --git a/tests/test-functions.php b/tests/test-functions.php index 682d0aa..154390c 100644 --- a/tests/test-functions.php +++ b/tests/test-functions.php @@ -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 );