Project

General

Profile

« Previous | Next » 

Revision 13696

web/username_prefix.php: user2path(): padding used to visually separate 1st element of URL: support embedded @ inside highlighted part

View differences:

username_prefix.php
8 8
function user2path($user) # multiple @ and nested . OK: a@b.c@url -> url?b.c.a
9 9
{
10 10
	# remove padding used to visually separate 1st element: _x_@url -> x@url
11
	$user = preg_replace('/^_*([^@]*?)_*(?=@|$)/', '$1', $user);
11
	# supports embedded @ inside highlighted part: _x@y_@url
12
	$user = preg_replace('/^_*(.*?)_*(?=@|$)/', '$1', $user);
12 13
	# translate reverse @-paths into forward .-paths
13 14
	return implode(".", array_reverse(explode("@", $user)));
14 15
}

Also available in: Unified diff