pixelfed/app/Util/Lexer/Nickname.php

24 lines
467 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
return ['domain' => $domain, 'username' => $username];
2018-04-20 01:16:27 +00:00
}
2018-08-28 03:07:36 +00:00
}