mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-07 10:41:40 +09:00
Add R\F\URL::getCurrentDomain()
This commit is contained in:
parent
5f47ddeb53
commit
8a012a5847
3 changed files with 38 additions and 3 deletions
|
|
@ -33,6 +33,23 @@ class URL
|
|||
/**
|
||||
* Get the current domain.
|
||||
*
|
||||
* @param bool $preserve_port
|
||||
* @return string
|
||||
*/
|
||||
public static function getCurrentDomain(bool $preserve_port = false): string
|
||||
{
|
||||
// Get current domain.
|
||||
$domain = strtolower($_SERVER['HTTP_HOST'] ?? '');
|
||||
if (!$preserve_port)
|
||||
{
|
||||
$domain = preg_replace('/:\d+$/', '', $domain);
|
||||
}
|
||||
return self::decodeIdna($domain);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a URL using the current domain and the path.
|
||||
*
|
||||
* @param string $path
|
||||
* @return string
|
||||
*/
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue