Skip to content

Commit

Permalink
Merge pull request #338 from jeremykendall/develop
Browse files Browse the repository at this point in the history
Prepare 6.1.2 releaase
  • Loading branch information
nyamsprod authored Sep 29, 2022
2 parents e195ab7 + 9a86c86 commit bc84e24
Show file tree
Hide file tree
Showing 8 changed files with 50 additions and 30 deletions.
2 changes: 0 additions & 2 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,5 @@ jobs:
- run: composer phpunit
- run: composer phpstan
if: ${{ matrix.php == '8.1' }}
- run: composer psalm
if: ${{ matrix.php == '8.1' }}
- run: composer phpcs
if: ${{ matrix.php == '8.1' }}
2 changes: 1 addition & 1 deletion .php-cs-fixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
'remove_inheritdoc' => true,
'allow_unused_params' => false,
],
'no_trailing_comma_in_singleline_array' => true,
'no_trailing_comma_in_singleline' => true,
'no_unused_imports' => true,
'ordered_imports' => ['imports_order' => ['class', 'function', 'const'], 'sort_algorithm' => 'alpha'],
'phpdoc_add_missing_param_annotation' => ['only_untyped' => true],
Expand Down
18 changes: 18 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,24 @@

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

## 6.1.2 - 2022-09-29

### Added

- None

### Fixed

- [#321](https://github.com/jeremykendall/php-domain-parser/issues/334) remove regression to resolving private domain suffix.

### Deprecated

- None

### Removed

- None

## 6.1.1 - 2022-02-18

### Added
Expand Down
8 changes: 2 additions & 6 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,9 @@
"phpstan/phpstan-phpunit": "^1.0.0",
"phpstan/phpstan-strict-rules": "^1.1.0",
"phpunit/phpunit": "^9.5.13",
"psalm/plugin-phpunit": "^0.15.2",
"psr/http-factory": "^1.0",
"psr/simple-cache": "^1.0",
"symfony/cache": "^v5.0",
"vimeo/psalm": "^4.20"
"symfony/cache": "^v5.0 || ^v6.0"
},
"suggest": {
"psr/http-client-implementation": "To use the storage functionnality which depends on PSR-18",
Expand All @@ -79,15 +77,13 @@
"test": [
"@phpunit",
"@phpstan",
"@psalm",
"@phpcs"
"@phpcs:fix"
]
},
"scripts-descriptions": {
"phpcs": "Runs coding style test suite",
"phpcs:fix": "Fix the package coding style",
"phpstan": "Runs complete codebase static analysis",
"psalm": "Runs complete codebase static analysis",
"phpunit": "Runs unit and functional testing",
"test": "Runs the complete test suite"
},
Expand Down
18 changes: 0 additions & 18 deletions psalm.xml

This file was deleted.

14 changes: 13 additions & 1 deletion src/Rules.php
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,8 @@ private function getPublicSuffixLengthFromSection(DomainName $domain, string $se
if (!array_key_exists($label, $rules)) {
// for private domain suffix MUST be fully matched else no suffix is found
// https://github.com/jeremykendall/php-domain-parser/issues/321
if (self::PRIVATE_DOMAINS === $section && [] !== $rules) {
// https://github.com/jeremykendall/php-domain-parser/issues/334
if (self::PRIVATE_DOMAINS === $section && self::hasRemainingRuleLabels($rules)) {
$labelCount = 0;
}
break;
Expand All @@ -317,4 +318,15 @@ private function getPublicSuffixLengthFromSection(DomainName $domain, string $se

return $labelCount;
}

private static function hasRemainingRuleLabels(array $rules): bool
{
foreach ($rules as $rule) {
if ([] !== $rule) {
return true;
}
}

return false;
}
}
15 changes: 15 additions & 0 deletions src/RulesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -611,4 +611,19 @@ public function testIssue321Failure(): void

self::$rules->getPrivateDomain('clientportal.virtualcloud.com.br');
}

public function testWithMultiLevelPrivateDomain(): void
{
$domain = self::$rules->resolve('test-domain.eu.org');

self::assertFalse($domain->suffix()->isICANN());
self::assertTrue($domain->suffix()->isPrivate());
self::assertSame('eu.org', $domain->suffix()->value());

$domain = self::$rules->resolve('test-domain.lt.eu.org');

self::assertFalse($domain->suffix()->isICANN());
self::assertTrue($domain->suffix()->isPrivate());
self::assertSame('lt.eu.org', $domain->suffix()->value());
}
}
3 changes: 1 addition & 2 deletions src/TopLevelDomains.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,12 +95,11 @@ public static function parse(string $content): array
foreach ($file as $line) {
$line = trim($line);
if ([] === $data) {
$data = self::extractHeader($line);
$data = self::extractHeader($line) + ['records' => []];
continue;
}

if (false === strpos($line, '#')) {
$data['records'] = $data['records'] ?? [];
$data['records'][self::extractRootZone($line)] = 1;
continue;
}
Expand Down

0 comments on commit bc84e24

Please sign in to comment.