Fix for RichEditor root page links being returned with empty hrefs. (#3085)
Fixes issue found in https://github.com/octobercms/october/issues/3064#issuecomment-326008148, specifically 2nd bullet point. Credit to @joltmode.
This commit is contained in:
parent
57d54eb882
commit
04bf359d8c
|
|
@ -224,6 +224,13 @@ class RichEditor extends FormWidgetBase
|
|||
$linkUrl = substr($linkUrl, strlen($baseUrl));
|
||||
}
|
||||
|
||||
/*
|
||||
* Root page fallback.
|
||||
*/
|
||||
if (strlen($linkUrl) === 0) {
|
||||
$linkUrl = '/';
|
||||
}
|
||||
|
||||
$linkName = str_repeat(' ', $level * 4);
|
||||
$linkName .= is_array($link) ? array_get($link, 'title', '') : $link;
|
||||
$result[] = ['name' => $linkName, 'url' => $linkUrl];
|
||||
|
|
|
|||
Loading…
Reference in New Issue