mirror of
https://github.com/friendica/friendica
synced 2024-11-20 09:03:40 +00:00
Detect the hostname when the URI is in the format data@host.tld
This commit is contained in:
parent
5a77f7c326
commit
fffc360c6a
1 changed files with 10 additions and 1 deletions
|
@ -397,15 +397,24 @@ function uri_to_guid($uri, $host = "") {
|
|||
// We have to avoid that different routines could accidentally create the same value
|
||||
$parsed = parse_url($uri);
|
||||
|
||||
// When the hostname isn't given, we take it from the uri
|
||||
if ($host == "") {
|
||||
// Is it in the format data@host.tld?
|
||||
if ((count($parsed) == 1) && strstr($uri, '@')) {
|
||||
$mailparts = explode('@', $uri);
|
||||
$host = array_pop($mailparts);
|
||||
} else {
|
||||
$host = $parsed["host"];
|
||||
}
|
||||
}
|
||||
|
||||
// We use a hash of the hostname as prefix for the guid
|
||||
$guid_prefix = hash("crc32", $host);
|
||||
|
||||
// Remove the scheme to make sure that "https" and "http" doesn't make a difference
|
||||
unset($parsed["scheme"]);
|
||||
|
||||
// Glue it together to be able to make a hash from it
|
||||
$host_id = implode("/", $parsed);
|
||||
|
||||
// We could use any hash algorithm since it isn't a security issue
|
||||
|
|
Loading…
Reference in a new issue