Commit d0ab3ca7 authored by catch's avatar catch

Issue #3110064 by idebr, chandrashekhar_srijan, Vidushi Mehta, ckng,...

Issue #3110064 by idebr, chandrashekhar_srijan, Vidushi Mehta, ckng, benjifisher, mikelutz: Migrate empty, <nolink> and <none> link field

(cherry picked from commit 9ca47a6c)
parent b62d0618
...@@ -60,10 +60,15 @@ public function __construct(array $configuration, $plugin_id, $plugin_definition ...@@ -60,10 +60,15 @@ public function __construct(array $configuration, $plugin_id, $plugin_definition
*/ */
protected function canonicalizeUri($uri) { protected function canonicalizeUri($uri) {
// If we already have a scheme, we're fine. // If we already have a scheme, we're fine.
if (empty($uri) || parse_url($uri, PHP_URL_SCHEME)) { if (parse_url($uri, PHP_URL_SCHEME)) {
return $uri; return $uri;
} }
// Empty URI and non-links are allowed.
if (empty($uri) || in_array($uri, ['<nolink>', '<none>'])) {
return 'route:<nolink>';
}
// Remove the <front> component of the URL. // Remove the <front> component of the URL.
if (strpos($uri, '<front>') === 0) { if (strpos($uri, '<front>') === 0) {
$uri = substr($uri, strlen('<front>')); $uri = substr($uri, strlen('<front>'));
......
...@@ -86,6 +86,18 @@ public function canonicalizeUriDataProvider() { ...@@ -86,6 +86,18 @@ public function canonicalizeUriDataProvider() {
'http://www.example.com/page#links', 'http://www.example.com/page#links',
'http://www.example.com/page#links', 'http://www.example.com/page#links',
], ],
'empty' => [
'',
'route:<nolink>',
],
'No link' => [
'<nolink>',
'route:<nolink>',
],
'none' => [
'<none>',
'route:<nolink>',
],
]; ];
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment