Hello,
as noted in this forum discussion:
https://moodle.org/mod/forum/discuss.php?d=358172
There are problems when using the URL resource with custom URL Schemes and the embed or auto-open behaviour.
I took a deeper look at the code and, as I thought, the problem is not with the URL module per se.
It is in the Moodle's "purify_html" that is used by the "clean_text"
function that is used inside "redirect" function.
2790 // because they do not support all valid external URLs.
2791 $url = preg_replace('/[\x00-\x1F\x7F]/', '', $url);
2792 $url = str_replace('"', '%22', $url);
2793 $encodedurl = preg_replace("/\&(?![a-zA-Z0-9#]{1,8};)/", "&", $url);
2794 $encodedurl = preg_replace('/^.*href="([^"]*)".*$/', "\\1", clean_text('<a href="'.$encodedurl. '" />', FORMAT_HTML));
2795 $url = str_replace('&', '&', $encodedurl);
1686 $text = purify_html($text, $options);
1687 }