Skip to content

Commit dccc924

Browse files
committed
[#321] bugfix suffix resolution for private domain
1 parent add17e6 commit dccc924

File tree

6 files changed

+2509
-918
lines changed

6 files changed

+2509
-918
lines changed

.github/workflows/build.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ jobs:
2323
- run: composer update --no-progress ${{ matrix.composer-flags }}
2424
- run: composer phpunit
2525
- run: composer phpstan
26-
if: ${{ matrix.php == '8.0' }}
26+
if: ${{ matrix.php == '8.1' }}
2727
- run: composer psalm
28-
if: ${{ matrix.php == '8.0' }}
28+
if: ${{ matrix.php == '8.1' }}
2929
- run: composer phpcs
30-
if: ${{ matrix.php == '8.0' }}
30+
if: ${{ matrix.php == '8.1' }}

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.1 - 2022-02-18
6+
7+
### Added
8+
9+
- None
10+
11+
### Fixed
12+
13+
- [#321](https://github.com/jeremykendall/php-domain-parser/issues/321) improve resolving private domain suffix
14+
15+
### Deprecated
16+
17+
- None
18+
19+
### Removed
20+
21+
- None
22+
523
## 6.1.0 - 2021-06-19
624

725
### Added

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
"ext-json": "*"
4747
},
4848
"require-dev": {
49-
"friendsofphp/php-cs-fixer": "^2.19||^3.0",
49+
"friendsofphp/php-cs-fixer": "^2.19||~v3.4.0",
5050
"guzzlehttp/guzzle": "^7.0",
5151
"guzzlehttp/psr7": "^1.6||^2.0",
5252
"phpstan/phpstan": "^0.12.89",

src/Rules.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,11 @@ private function getPublicSuffixLengthFromSection(DomainName $domain, string $se
302302

303303
//no match found
304304
if (!array_key_exists($label, $rules)) {
305+
// for private domain suffix MUST be fully matched else no suffix is found
306+
// https://github.com/jeremykendall/php-domain-parser/issues/321
307+
if (self::PRIVATE_DOMAINS === $section && [] !== $rules) {
308+
$labelCount = 0;
309+
}
305310
break;
306311
}
307312

src/RulesTest.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -593,4 +593,15 @@ public function effectiveTLDProvider(): iterable
593593
],
594594
];
595595
}
596+
597+
public function testIssue321(): void
598+
{
599+
$result = self::$rules->resolve('node857-gelofesta.users.scale.virtualcloud.com.br');
600+
self::assertSame('users.scale.virtualcloud.com.br', $result->suffix()->value());
601+
self::assertTrue($result->suffix()->isPrivate());
602+
603+
$result = self::$rules->resolve('clientportal.virtualcloud.com.br');
604+
self::assertSame('com.br', $result->suffix()->value());
605+
self::assertTrue($result->suffix()->isICANN());
606+
}
596607
}

0 commit comments

Comments
 (0)