diff --git a/lib/NativeDecoder.php b/lib/NativeDecoder.php index 29b30ee..9919a8c 100644 --- a/lib/NativeDecoder.php +++ b/lib/NativeDecoder.php @@ -97,10 +97,7 @@ class NativeDecoder { /** @var \LibDNS\Records\Types\DomainName $domainName */ $domainName = $this->typeBuilder->build(Types::DOMAIN_NAME); - $labels = \explode('.', $name); - if ('' !== $last = \array_pop($labels)) { - $labels[] = $last; - } + $labels = \explode('.', rtrim($name, '.')); $domainName->setLabels($labels); $question = $this->questionFactory->create($type); @@ -190,10 +187,7 @@ class NativeDecoder if (!$encodingContext->isTruncated()) { /** @var \LibDNS\Records\Types\DomainName $domainName */ $domainName = $this->typeBuilder->build(Types::DOMAIN_NAME); - $labels = \explode('.', $record['host']); - if ('' !== $last = \array_pop($labels)) { - $labels[] = $last; - } + $labels = \explode('.', rtrim($record['host'], '.')); $domainName->setLabels($labels); $packet = $encodingContext->getPacket();