Extend MD_STD_IN::sanitize_url to automatically set protocol / scheme
names in lowercase
This commit is contained in:
@ -233,8 +233,16 @@ final class MD_STD_IN {
|
||||
}
|
||||
|
||||
// Check for valid schemes
|
||||
if (MD_STD::startsWithAny($output, ['https://', 'http://', 'ftp://']) === false) {
|
||||
throw new MDInvalidUrl("Invalid input URL");
|
||||
try {
|
||||
if (MD_STD::startsWithAny($output, ['https://', 'http://', 'ftp://']) === false) {
|
||||
throw new MDInvalidUrl("Invalid input URL" . PHP_EOL . $output . PHP_EOL . strtolower($output));
|
||||
}
|
||||
}
|
||||
catch (MDInvalidUrl $e) {
|
||||
if (MD_STD::startsWithAny(strtolower($output), ['https://', 'http://', 'ftp://']) === true) {
|
||||
$output = strtolower(substr($output, 0, 8)) . substr($output, 8);
|
||||
}
|
||||
else throw $e;
|
||||
}
|
||||
|
||||
if (\str_contains($output, '.') === false) {
|
||||
|
Reference in New Issue
Block a user