From ceaa3a424132ff4e8f798920e96b5ce470fd0ce5 Mon Sep 17 00:00:00 2001 From: Matthias Pfefferle Date: Sun, 18 Aug 2019 23:27:06 +0200 Subject: [PATCH] changed regex logic and added some more changes --- activitypub.php | 5 ++++- tests/test-class-activitypub-hashtag.php | 7 +++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/activitypub.php b/activitypub.php index 1da74bf..562fa1a 100644 --- a/activitypub.php +++ b/activitypub.php @@ -19,7 +19,7 @@ namespace Activitypub; * Initialize plugin */ function init() { - defined( 'ACTIVITYPUB_HASHTAGS_REGEXP' ) || define( 'ACTIVITYPUB_HASHTAGS_REGEXP', '(?<=[\s>]|^)#(\w*[A-Za-z_]+\w*)\b(?!;)' ); + defined( 'ACTIVITYPUB_HASHTAGS_REGEXP' ) || define( 'ACTIVITYPUB_HASHTAGS_REGEXP', '(?:(?<=\s)|^)#(\w*[A-Za-z_]+\w*)' ); require_once dirname( __FILE__ ) . '/includes/class-signature.php'; require_once dirname( __FILE__ ) . '/includes/class-activity.php'; @@ -59,6 +59,9 @@ function init() { require_once dirname( __FILE__ ) . '/includes/class-hashtag.php'; \Activitypub\Hashtag::init(); + + require_once dirname( __FILE__ ) . '/includes/class-health-check.php'; + \Activitypub\Health_Check::init(); } add_action( 'plugins_loaded', '\Activitypub\init' ); diff --git a/tests/test-class-activitypub-hashtag.php b/tests/test-class-activitypub-hashtag.php index b26681f..805445b 100644 --- a/tests/test-class-activitypub-hashtag.php +++ b/tests/test-class-activitypub-hashtag.php @@ -19,6 +19,13 @@ class Test_Activitypub_Hashtag extends WP_UnitTestCase { array( '#test', '#test' ), array( 'hallo #test test', 'hallo #test test' ), array( 'hallo #object test', 'hallo test' ), + array( 'hallo test test', 'hallo test test' ), + array( 'hallo #test test', 'hallo #test test' ), + array( '
hallo #object test
', '
hallo test
' ), + array( '
hallo #object
', '
hallo
' ), + array( '
#object
', '
#object
' ), + array( '#object', '#object' ), + array( '
object', '
object' ), ); } }