Skip to content

Commit 4a76d50

Browse files
committed
Iterate over all remaining labels to avoid missing suffix
1 parent 0daa3be commit 4a76d50

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

src/Rules.php

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ private function getPublicSuffixLengthFromSection(DomainName $domain, string $se
278278
// for private domain suffix MUST be fully matched else no suffix is found
279279
// https://github.com/jeremykendall/php-domain-parser/issues/321
280280
// https://github.com/jeremykendall/php-domain-parser/issues/334
281-
if (self::PRIVATE_DOMAINS === $section && [] !== $rules && [] !== reset($rules)) {
281+
if (self::PRIVATE_DOMAINS === $section && self::hasRemainingRuleLabels($rules)) {
282282
$labelCount = 0;
283283
}
284284
break;
@@ -291,4 +291,15 @@ private function getPublicSuffixLengthFromSection(DomainName $domain, string $se
291291

292292
return $labelCount;
293293
}
294+
295+
private static function hasRemainingRuleLabels(array $rules): bool
296+
{
297+
foreach ($rules as $rule) {
298+
if ([] !== $rule) {
299+
return true;
300+
}
301+
}
302+
303+
return false;
304+
}
294305
}

0 commit comments

Comments
 (0)