diff --git a/src/Powerdns.php b/src/Powerdns.php index bb1d585..1e293a7 100644 --- a/src/Powerdns.php +++ b/src/Powerdns.php @@ -148,12 +148,8 @@ public function useKey(string $key): PowerdnsInterface */ public function createZone(string $canonicalDomain, array $nameservers, bool $useDnssec = false): Zone { - $fixDot = substr($canonicalDomain, -1) !== '.'; - - if ($fixDot) { - $canonicalDomain .= '.'; - } + $canonicalDomain = rtrim($canonicalDomain, ".") . "."; $newZone = new ZoneResource(); $newZone->setName($canonicalDomain); $newZone->setNameservers($nameservers); diff --git a/src/Resources/Zone.php b/src/Resources/Zone.php index b4adcaf..84b26dc 100644 --- a/src/Resources/Zone.php +++ b/src/Resources/Zone.php @@ -453,7 +453,9 @@ public function setApiRectify(bool $apiRectify): self */ public function setNameservers(array $nameservers): self { - $this->nameservers = $nameservers; + $this->nameservers = array_map(function($ns) { + return rtrim($ns, '.') . '.'; + }, $nameservers); return $this; } diff --git a/tests/Resources/ZoneTest.php b/tests/Resources/ZoneTest.php index 79c0cfc..888aef1 100644 --- a/tests/Resources/ZoneTest.php +++ b/tests/Resources/ZoneTest.php @@ -65,11 +65,10 @@ public function testSetApiResponseWithoutOptionalData(): void $this->assertNull($zone->getAccount()); } - public function testSetNameservers(): void - { + public function testSetNameserversCanoncial(): void { $zone = new Zone(); - $zone->setNameservers(['foo', 'bar']); - $this->assertSame(['foo', 'bar'], $zone->getNameservers()); + $zone->setNameservers(['ns1', 'ns2']); + $this->assertSame(['ns1.', 'ns2.'], $zone->getNameservers()); } public function testSetKind(): void