mirror of
https://github.com/sourcegit-scm/sourcegit
synced 2025-05-21 12:15:00 +00:00
refactor<*>: rewrite all with AvaloniaUI
This commit is contained in:
parent
0136904612
commit
2a62596999
521 changed files with 19780 additions and 23244 deletions
|
@ -1,10 +1,31 @@
|
|||
namespace SourceGit.Models {
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
/// <summary>
|
||||
/// 远程
|
||||
/// </summary>
|
||||
namespace SourceGit.Models {
|
||||
public class Remote {
|
||||
private static readonly Regex[] URL_FORMATS = [
|
||||
new Regex(@"^http[s]?://([\w\-]+@)?[\w\.\-]+(\:[0-9]+)?/[\w\-]+/[\w\-\.]+\.git$"),
|
||||
new Regex(@"^[\w\-]+@[\w\.\-]+(\:[0-9]+)?:[\w\-]+/[\w\-\.]+\.git$"),
|
||||
new Regex(@"^ssh://([\w\-]+@)?[\w\.\-]+(\:[0-9]+)?/[\w\-]+/[\w\-\.]+\.git$"),
|
||||
];
|
||||
|
||||
public string Name { get; set; }
|
||||
public string URL { get; set; }
|
||||
|
||||
public static bool IsSSH(string url) {
|
||||
if (string.IsNullOrWhiteSpace(url)) return false;
|
||||
|
||||
for (int i = 1; i < URL_FORMATS.Length; i++) {
|
||||
if (URL_FORMATS[i].IsMatch(url)) return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static bool IsValidURL(string url) {
|
||||
foreach (var fmt in URL_FORMATS) {
|
||||
if (fmt.IsMatch(url)) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue