1
0
Fork 1
mirror of https://github.com/pixelfed/pixelfed.git synced 2024-12-30 19:55:10 +00:00
pixelfed/app/Util/Lexer/Nickname.php
2021-02-03 20:55:49 -07:00

36 lines
700 B
PHP

<?php
namespace App\Util\Lexer;
use Illuminate\Support\Str;
class Nickname
{
public static function normalizeProfileUrl($url)
{
if(!Str::of($url)->contains('@')) {
return;
}
if(Str::startsWith($url, 'acct:')) {
$url = str_replace('acct:', '', $url);
}
if(Str::startsWith($url, '@')) {
$url = substr($url, 1);
if(!Str::of($url)->contains('@')) {
return;
}
}
$parts = explode('@', $url);
$username = $parts[0];
$domain = $parts[1];
return [
'domain' => $domain,
'username' => $username
];
}
}