Merge pull request #8 from Tikuf42/master

URL Validation
This commit is contained in:
Madpeterz 2020-05-02 07:29:36 +01:00 committed by GitHub
commit 5080f2e5cd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -19,7 +19,14 @@ namespace BSB.Commands.script
{ {
string attempt_endpoint = args[0]; string attempt_endpoint = args[0];
if(attempt_endpoint.Contains("https://github.com/")) Uri uriResult;
bool urlValid = Uri.TryCreate(attempt_endpoint, UriKind.Absolute, out uriResult)
&& (uriResult.Scheme == Uri.UriSchemeHttp || uriResult.Scheme == Uri.UriSchemeHttps);
if(urlValid == false)
{
return Failed("Url >" + attempt_endpoint + "< is not a valid URL");
}
if (attempt_endpoint.Contains("https://github.com/"))
{ {
attempt_endpoint = attempt_endpoint.Replace("https://github.com/", "https://raw.githubusercontent.com/"); attempt_endpoint = attempt_endpoint.Replace("https://github.com/", "https://raw.githubusercontent.com/");
} }