Skip to content

Commit

Permalink
CapitalPDangit: minor tweak
Browse files Browse the repository at this point in the history
Allow for the `test` TLD.

Includes unit test.
  • Loading branch information
jrfnl committed Oct 3, 2019
1 parent 0d2f984 commit 85f3016
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
4 changes: 2 additions & 2 deletions WordPress/Sniffs/WP/CapitalPDangitSniff.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class CapitalPDangitSniff extends Sniff {
* Regex to match a large number or spelling variations of WordPress in text strings.
*
* Prevents matches on:
* - URLs for wordpress.org/com/net/tv.
* - URLs for wordpress.org/com/net/test/tv.
* - `@...` usernames starting with `wordpress`
* - email addresses with a domain starting with `wordpress`
* - email addresses with a user name ending with `wordpress`
Expand All @@ -42,7 +42,7 @@ class CapitalPDangitSniff extends Sniff {
*
* @var string
*/
const WP_REGEX = '#(?<![\\\\/\$@`-])\b(Word[ _-]*Pres+)\b(?![@/`-]|\.(?:org|com|net|tv)|[^\s<>\'"()]*?\.(?:php|js|css|png|j[e]?pg|gif|pot))#i';
const WP_REGEX = '#(?<![\\\\/\$@`-])\b(Word[ _-]*Pres+)\b(?![@/`-]|\.(?:org|com|net|test|tv)|[^\s<>\'"()]*?\.(?:php|js|css|png|j[e]?pg|gif|pot))#i';

/**
* Regex to match a large number or spelling variations of WordPress in class names.
Expand Down
3 changes: 3 additions & 0 deletions WordPress/Tests/WP/CapitalPDangitUnitTest.inc
Original file line number Diff line number Diff line change
Expand Up @@ -188,3 +188,6 @@ class TestMe {
ANOTHER => array( 'a' => 'b' ),
WORDPRESS_SOMETHING = 'wordpress'; // OK (complex declaration to make sure start of statement is detected correctly).
}

// Allow "test" domain.
$value = function_call( 'git.wordpress.test' );
3 changes: 3 additions & 0 deletions WordPress/Tests/WP/CapitalPDangitUnitTest.inc.fixed
Original file line number Diff line number Diff line change
Expand Up @@ -188,3 +188,6 @@ class TestMe {
ANOTHER => array( 'a' => 'b' ),
WORDPRESS_SOMETHING = 'wordpress'; // OK (complex declaration to make sure start of statement is detected correctly).
}

// Allow "test" domain.
$value = function_call( 'git.wordpress.test' );

0 comments on commit 85f3016

Please sign in to comment.