Skip to content

Commit bc84e24

Browse files
authored
Merge pull request #338 from jeremykendall/develop
Prepare 6.1.2 releaase
2 parents e195ab7 + 9a86c86 commit bc84e24

File tree

8 files changed

+50
-30
lines changed

8 files changed

+50
-30
lines changed

.github/workflows/build.yaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,5 @@ jobs:
2424
- run: composer phpunit
2525
- run: composer phpstan
2626
if: ${{ matrix.php == '8.1' }}
27-
- run: composer psalm
28-
if: ${{ matrix.php == '8.1' }}
2927
- run: composer phpcs
3028
if: ${{ matrix.php == '8.1' }}

.php-cs-fixer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
'remove_inheritdoc' => true,
2828
'allow_unused_params' => false,
2929
],
30-
'no_trailing_comma_in_singleline_array' => true,
30+
'no_trailing_comma_in_singleline' => true,
3131
'no_unused_imports' => true,
3232
'ordered_imports' => ['imports_order' => ['class', 'function', 'const'], 'sort_algorithm' => 'alpha'],
3333
'phpdoc_add_missing_param_annotation' => ['only_untyped' => true],

CHANGELOG.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,24 @@
22

33
All Notable changes to `PHP Domain Parser` starting from the **5.x** series will be documented in this file
44

5+
## 6.1.2 - 2022-09-29
6+
7+
### Added
8+
9+
- None
10+
11+
### Fixed
12+
13+
- [#321](https://github.com/jeremykendall/php-domain-parser/issues/334) remove regression to resolving private domain suffix.
14+
15+
### Deprecated
16+
17+
- None
18+
19+
### Removed
20+
21+
- None
22+
523
## 6.1.1 - 2022-02-18
624

725
### Added

composer.json

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,9 @@
5353
"phpstan/phpstan-phpunit": "^1.0.0",
5454
"phpstan/phpstan-strict-rules": "^1.1.0",
5555
"phpunit/phpunit": "^9.5.13",
56-
"psalm/plugin-phpunit": "^0.15.2",
5756
"psr/http-factory": "^1.0",
5857
"psr/simple-cache": "^1.0",
59-
"symfony/cache": "^v5.0",
60-
"vimeo/psalm": "^4.20"
58+
"symfony/cache": "^v5.0 || ^v6.0"
6159
},
6260
"suggest": {
6361
"psr/http-client-implementation": "To use the storage functionnality which depends on PSR-18",
@@ -79,15 +77,13 @@
7977
"test": [
8078
"@phpunit",
8179
"@phpstan",
82-
"@psalm",
83-
"@phpcs"
80+
"@phpcs:fix"
8481
]
8582
},
8683
"scripts-descriptions": {
8784
"phpcs": "Runs coding style test suite",
8885
"phpcs:fix": "Fix the package coding style",
8986
"phpstan": "Runs complete codebase static analysis",
90-
"psalm": "Runs complete codebase static analysis",
9187
"phpunit": "Runs unit and functional testing",
9288
"test": "Runs the complete test suite"
9389
},

psalm.xml

Lines changed: 0 additions & 18 deletions
This file was deleted.

src/Rules.php

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,8 @@ private function getPublicSuffixLengthFromSection(DomainName $domain, string $se
304304
if (!array_key_exists($label, $rules)) {
305305
// for private domain suffix MUST be fully matched else no suffix is found
306306
// https://github.com/jeremykendall/php-domain-parser/issues/321
307-
if (self::PRIVATE_DOMAINS === $section && [] !== $rules) {
307+
// https://github.com/jeremykendall/php-domain-parser/issues/334
308+
if (self::PRIVATE_DOMAINS === $section && self::hasRemainingRuleLabels($rules)) {
308309
$labelCount = 0;
309310
}
310311
break;
@@ -317,4 +318,15 @@ private function getPublicSuffixLengthFromSection(DomainName $domain, string $se
317318

318319
return $labelCount;
319320
}
321+
322+
private static function hasRemainingRuleLabels(array $rules): bool
323+
{
324+
foreach ($rules as $rule) {
325+
if ([] !== $rule) {
326+
return true;
327+
}
328+
}
329+
330+
return false;
331+
}
320332
}

src/RulesTest.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -611,4 +611,19 @@ public function testIssue321Failure(): void
611611

612612
self::$rules->getPrivateDomain('clientportal.virtualcloud.com.br');
613613
}
614+
615+
public function testWithMultiLevelPrivateDomain(): void
616+
{
617+
$domain = self::$rules->resolve('test-domain.eu.org');
618+
619+
self::assertFalse($domain->suffix()->isICANN());
620+
self::assertTrue($domain->suffix()->isPrivate());
621+
self::assertSame('eu.org', $domain->suffix()->value());
622+
623+
$domain = self::$rules->resolve('test-domain.lt.eu.org');
624+
625+
self::assertFalse($domain->suffix()->isICANN());
626+
self::assertTrue($domain->suffix()->isPrivate());
627+
self::assertSame('lt.eu.org', $domain->suffix()->value());
628+
}
614629
}

src/TopLevelDomains.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,12 +95,11 @@ public static function parse(string $content): array
9595
foreach ($file as $line) {
9696
$line = trim($line);
9797
if ([] === $data) {
98-
$data = self::extractHeader($line);
98+
$data = self::extractHeader($line) + ['records' => []];
9999
continue;
100100
}
101101

102102
if (false === strpos($line, '#')) {
103-
$data['records'] = $data['records'] ?? [];
104103
$data['records'][self::extractRootZone($line)] = 1;
105104
continue;
106105
}

0 commit comments

Comments
 (0)