Skip to content

Commit

Permalink
Update Namecheap use Util for determining if locking is enabled - add…
Browse files Browse the repository at this point in the history
… de to disabled list
  • Loading branch information
uphlewis committed Jun 14, 2023
1 parent fc5902b commit 09d61fd
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 12 deletions.
13 changes: 13 additions & 0 deletions src/Helper/Utils.php
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,19 @@ public static function lookupNameservers(string $domain, bool $orFail = true): ?
}
}

/**
* Determine whether the registry of the given TLD supports domain locking.
*/
public static function tldSupportsLocking(string $tld): bool
{
$unsupported = [
'io',
'de',
];

return !in_array(static::getRootTld($tld), $unsupported);
}

/**
* Determine whether the registry of the given TLD supports explicit renewal.
*/
Expand Down
8 changes: 1 addition & 7 deletions src/Namecheap/Helper/NamecheapApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,6 @@ class NamecheapApi
*/
protected const ALLOWED_CONTACT_TYPES = ['registrant', 'tech', 'admin', 'auxbilling'];

public const NO_LOCK_TLDS = [
'io',
];

/**
* Contact Types
*/
Expand Down Expand Up @@ -311,9 +307,7 @@ public function getRegistrarLockStatus(string $domainName): bool
'DomainName' => $domainName,
];

$tld = Utils::getTld($domainName);

if (in_array($tld, self::NO_LOCK_TLDS)) {
if (!Utils::tldSupportsLocking(Utils::getTld($domainName))) {
return false;
}

Expand Down
7 changes: 2 additions & 5 deletions src/Namecheap/Provider.php
Original file line number Diff line number Diff line change
Expand Up @@ -382,11 +382,8 @@ public function setLock(LockParams $params): DomainResult
$lock = !!$params->lock;

try {
if (in_array($params->tld, NamecheapApi::NO_LOCK_TLDS)) {
throw $this->errorResult(
sprintf('Domain %s does not support to change Registrar Lock.', $domainName),
$params
);
if (!Utils::tldSupportsLocking($params->tld)) {
throw $this->errorResult(sprintf('%s domains do not support locking', $params->tld));
}

$currentLockStatus = $this->api()->getRegistrarLockStatus($domainName);
Expand Down

0 comments on commit 09d61fd

Please sign in to comment.