Skip to content

Commit

Permalink
fix wildcard-domain matching
Browse files Browse the repository at this point in the history
  • Loading branch information
Jalle19 committed Feb 5, 2014
1 parent 13a04e0 commit f889e61
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Whitelist/Definition/WildcardDomain.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public function validate()
public function match($value)
{
// Remove the wildcard part and check if it matches the end of $value
$domain = substr($this->_definition, 2);
$domain = substr($this->_definition, 1);

return substr($value, -strlen($domain)) === $domain;
}
Expand Down
3 changes: 3 additions & 0 deletions tests/Definition/DomainTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ public function provider()
return array(
array(true, new Whitelist\Definition\WildcardDomain('*.example.com'), 'sub.example.com'),
array(true, new Whitelist\Definition\WildcardDomain('*.example.com'), 'anothersub.example.com'),
array(false, new Whitelist\Definition\WildcardDomain('*.example.com'), 'sub.example.net'),
array(false, new Whitelist\Definition\WildcardDomain('*.example.com'), 'sub.anotherexample.com'),
array(false, new Whitelist\Definition\WildcardDomain('*.example.com'), 'localhost'),
array(true, new Whitelist\Definition\Domain('example.com'), 'example.com'),
array(false, new Whitelist\Definition\Domain('example.com'), 'sub.example.com'),
array(false, new Whitelist\Definition\Domain('example.com'), 'example2.com'),
Expand Down

0 comments on commit f889e61

Please sign in to comment.