Skip to content
Snippets Groups Projects
Commit e63abfae authored by Hussain Abbas's avatar Hussain Abbas Committed by Hussain Abbas
Browse files

Issue #3464064 by nicxvan, hussainweb: Usernames with Spaces do not work

parent 7abbd9a5
No related branches found
No related tags found
No related merge requests found
......@@ -105,10 +105,20 @@ class DrupalOrgUsernameFormatter extends FormatterBase {
$attributes['target'] = $settings['target'];
}
$username = $item->value;
// Try to get the URL from the API first. But we may not always be able to
// get it. This could be due to an invalid username or many other reasons.
// In that case, we just generate a dummy URL assuming the best.
$url = $item->getProperties(TRUE)['url']->getValue();
if (!$url) {
$url = 'https://www.drupal.org/u/' . str_replace(" ", "-", strtolower($username));
}
return [
'#type' => 'link',
'#title' => $item->value,
'#url' => Url::fromUri('https://www.drupal.org/u/' . $item->value, [
'#title' => $username,
'#url' => Url::fromUri($url, [
'attributes' => $attributes,
]),
];
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment