Skip to content

Commit 400d454

Browse files
committed
enhance: a more adaptable regular expression for remote URLs (#61)
1 parent 040a6d4 commit 400d454

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

src/Models/Remote.cs

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,17 @@ namespace SourceGit.Models
44
{
55
public partial class Remote
66
{
7-
8-
[GeneratedRegex(@"^http[s]?://([\w\-]+@)?[\w\.\-]+(\:[0-9]+)?/[\w\-]+/[\w\-\.]+\.git$")]
9-
private static partial Regex regex1();
10-
7+
[GeneratedRegex(@"^http[s]?://([\w\-]+@)?[\w\.\-]+(\:[0-9]+)?/[\w\-/]+/[\w\-\.]+\.git$")]
8+
private static partial Regex REG_HTTPS();
119
[GeneratedRegex(@"^[\w\-]+@[\w\.\-]+(\:[0-9]+)?:[\w\-]+/[\w\-\.]+\.git$")]
12-
private static partial Regex regex2();
10+
private static partial Regex REG_SSH1();
1311
[GeneratedRegex(@"^ssh://([\w\-]+@)?[\w\.\-]+(\:[0-9]+)?/[\w\-]+/[\w\-\.]+\.git$")]
14-
private static partial Regex regex3();
12+
private static partial Regex REG_SSH2();
1513

1614
private static readonly Regex[] URL_FORMATS = [
17-
regex1(),
18-
regex2(),
19-
regex3(),
15+
REG_HTTPS(),
16+
REG_SSH1(),
17+
REG_SSH2(),
2018
];
2119

2220
public string Name { get; set; }

0 commit comments

Comments
 (0)