public static function LibraryPolicyBuilder::getHostFromUri in Content-Security-Policy 8
Get host info from a URI.
Parameters
string $uri: The URI.
Return value
string The host info.
1 call to LibraryPolicyBuilder::getHostFromUri()
- LibraryPolicyBuilder::getLibrarySources in src/
LibraryPolicyBuilder.php - Get the required sources for a single library.
File
- src/
LibraryPolicyBuilder.php, line 216
Class
- LibraryPolicyBuilder
- Service to build policy information for libraries.
Namespace
Drupal\cspCode
public static function getHostFromUri($uri) {
$uri = new Uri($uri);
$host = $uri
->getHost();
// Only include scheme if restricted to HTTPS.
if ($uri
->getScheme() === 'https') {
$host = 'https://' . $host;
}
if ($port = $uri
->getPort()) {
$host .= ':' . $port;
}
return $host;
}