1
0
Fork 0
forked from mirror/pixelfed
pixelfed/app/Util/Lexer/Nickname.php

26 lines
557 B
PHP
Raw Normal View History

2018-04-20 01:16:27 +00:00
<?php
namespace App\Util\Lexer;
2018-08-28 03:07:36 +00:00
class Nickname
{
2018-04-20 01:16:27 +00:00
public static function normalizeProfileUrl($url)
{
2018-08-28 03:07:36 +00:00
if (starts_with($url, 'acct:')) {
$url = str_replace('acct:', '', $url);
}
2018-04-20 01:16:27 +00:00
if(starts_with($url, '@')) {
$url = substr($url, 1);
2018-04-20 01:16:27 +00:00
}
2018-08-28 03:07:36 +00:00
$parts = explode('@', $url);
$username = $parts[0];
$domain = $parts[1];
2018-08-28 03:07:36 +00:00
if(parse_url(filter_var('https://test.dev', FILTER_VALIDATE_URL), PHP_URL_HOST))
2018-04-20 01:16:27 +00:00
2018-08-28 03:07:36 +00:00
return ['domain' => $domain, 'username' => $username];
2018-04-20 01:16:27 +00:00
}
2018-08-28 03:07:36 +00:00
}