-
Notifications
You must be signed in to change notification settings - Fork 24
/
Copy pathURLFormatter.cs
38 lines (31 loc) · 1.04 KB
/
URLFormatter.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Text.RegularExpressions;
namespace Launcher
{
class URLFormatter
{
private static string httpPattern = @"http:\/\/";
private static string wwwPattern = "www";
private static string setRealmlistPattern = @"set\srealmlist\s";
public static string format(string url)
{
if (!Regex.Match(url, httpPattern).Success)
url = "http://" + url;
return Regex.Replace(url, " ", "");
}
public static string formatPingUrl(string url)
{
if (Regex.Match(url, httpPattern).Success)
url = Regex.Replace(url, httpPattern, "");
if (Regex.Match(url, wwwPattern).Success)
url = Regex.Replace(url, wwwPattern, "");
if (Regex.Match(url, setRealmlistPattern).Success)
url = Regex.Replace(url, setRealmlistPattern, "");
return url;
}
}
}