mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-12-30 08:53:17 +00:00
36 lines
700 B
PHP
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
|
|
];
|
|
}
|
|
}
|