Changeset View
Changeset View
Standalone View
Standalone View
src/workflow/ArcanistInstallCertificateWorkflow.php
Show First 20 Lines • Show All 190 Lines • ▼ Show 20 Lines | if (count($uri) > 1) { | ||||
pht( | pht( | ||||
'Specify an explicit URI or run this command from within a '. | 'Specify an explicit URI or run this command from within a '. | ||||
'project which is configured with a %s.', | 'project which is configured with a %s.', | ||||
'.arcconfig')); | '.arcconfig')); | ||||
} | } | ||||
$uri = $conduit_uri; | $uri = $conduit_uri; | ||||
} | } | ||||
$example = 'https://phabricator.example.com/'; | |||||
$uri_object = new PhutilURI($uri); | $uri_object = new PhutilURI($uri); | ||||
if (!$uri_object->getProtocol() || !$uri_object->getDomain()) { | $protocol = $uri_object->getProtocol(); | ||||
if (!$protocol || !$uri_object->getDomain()) { | |||||
throw new ArcanistUsageException( | throw new ArcanistUsageException( | ||||
pht( | pht( | ||||
'Server URI "%s" must include a protocol and domain. It should be '. | 'Server URI "%s" must include a protocol and domain. It should be '. | ||||
'in the form "%s".', | 'in the form "%s".', | ||||
$uri, | $uri, | ||||
'https://phabricator.example.com/')); | $example)); | ||||
} | |||||
$protocol = $uri_object->getProtocol(); | |||||
switch ($protocol) { | |||||
case 'http': | |||||
case 'https': | |||||
break; | |||||
default: | |||||
throw new ArcanistUsageException( | |||||
pht( | |||||
'Server URI "%s" must include the "http" or "https" protocol. '. | |||||
'It should be in the form "%s".', | |||||
$uri, | |||||
$example)); | |||||
} | } | ||||
$uri_object->setPath('/api/'); | $uri_object->setPath('/api/'); | ||||
return (string)$uri_object; | return (string)$uri_object; | ||||
} | } | ||||
} | } |