wasSharp – Diff between revs 27 and 32
?pathlinks?
Rev 27 | Rev 32 | |||
---|---|---|---|---|
Line 76... | Line 76... | |||
76 | } |
76 | } |
|
Line 77... | Line 77... | |||
77 | |
77 | |
|
78 | /////////////////////////////////////////////////////////////////////////// |
78 | /////////////////////////////////////////////////////////////////////////// |
|
79 | // Copyright (C) Wizardry and Steamworks 2015 - License: GNU GPLv3 // |
79 | // Copyright (C) Wizardry and Steamworks 2015 - License: GNU GPLv3 // |
|
- | 80 | /////////////////////////////////////////////////////////////////////////// |
||
80 | /////////////////////////////////////////////////////////////////////////// |
81 | /// <summary>Retrieves the port from an HttpListener prefix</summary> |
|
81 | /// <param name="prefix">a HttpListener prefix</param> |
82 | /// <param name="prefix">a HttpListener prefix</param> |
|
82 | /// <returns>the port of the HttpListener</returns> |
83 | /// <returns>the port of the HttpListener</returns> |
|
83 | public static long GetPortFromPrefix(this string prefix) |
84 | public static long GetPortFromPrefix(this string prefix) |
|
84 | { |
85 | { |
|
Line 88... | Line 89... | |||
88 | "$2" |
89 | "$2" |
|
89 | ).Split(':'); |
90 | ).Split(':'); |
|
90 | long port; |
91 | long port; |
|
91 | return split.Length <= 1 || !long.TryParse(split[1], out port) ? 80 : port; |
92 | return split.Length <= 1 || !long.TryParse(split[1], out port) ? 80 : port; |
|
92 | } |
93 | } |
|
- | 94 | |
||
- | 95 | /////////////////////////////////////////////////////////////////////////// |
||
- | 96 | // Copyright (C) Wizardry and Steamworks 2017 - License: GNU GPLv3 // |
||
- | 97 | /////////////////////////////////////////////////////////////////////////// |
||
- | 98 | /// <summary> |
||
- | 99 | /// Compare Two URIs |
||
- | 100 | /// </summary> |
||
- | 101 | /// <param name="l">the URI to compare</param> |
||
- | 102 | /// <param name="r">the URI to compare to</param> |
||
- | 103 | /// <param name="components">optionally the components to compare</param> |
||
- | 104 | /// <returns>true if the URIs match</returns> |
||
- | 105 | public static bool UriIsEqualTo(this string l, string r, |
||
- | 106 | UriComponents components = UriComponents.Host | UriComponents.PathAndQuery) |
||
- | 107 | { |
||
- | 108 | try |
||
- | 109 | { |
||
- | 110 | Uri a = new Uri(l); |
||
- | 111 | Uri b = new Uri(r); |
||
- | 112 | |
||
- | 113 | return Uri.Compare(a, b, components, |
||
- | 114 | UriFormat.SafeUnescaped, StringComparison.OrdinalIgnoreCase) == 0; |
||
- | 115 | } |
||
- | 116 | catch |
||
- | 117 | { |
||
- | 118 | return false; |
||
- | 119 | } |
||
- | 120 | } |
||
93 | } |
121 | } |
|
94 | } |
122 | } |