fix<SubmodulePathRequiredRule>: relative path for submodule is optional.

This commit is contained in:
leo 2021-04-12 09:17:44 +08:00
parent 344a603665
commit 29658a7966

View file

@ -130,9 +130,11 @@ namespace SourceGit.Helpers {
/// </summary> /// </summary>
public class SubmodulePathRequiredRule : ValidationRule { public class SubmodulePathRequiredRule : ValidationRule {
public override ValidationResult Validate(object value, CultureInfo cultureInfo) { public override ValidationResult Validate(object value, CultureInfo cultureInfo) {
var regex = new Regex(@"^[\w\-\._/]+$");
var path = value as string; var path = value as string;
var succ = !string.IsNullOrEmpty(path) && regex.IsMatch(path.Trim()); if (string.IsNullOrEmpty(path)) return ValidationResult.ValidResult;
var regex = new Regex(@"^[\w\-\._/]+$");
var succ = regex.IsMatch(path.Trim());
return !succ ? new ValidationResult(false, App.Text("BadSubmodulePath")) : ValidationResult.ValidResult; return !succ ? new ValidationResult(false, App.Text("BadSubmodulePath")) : ValidationResult.ValidResult;
} }
} }