| | 1 | | // Copyright (c) Microsoft Corporation. All rights reserved. |
| | 2 | | // Licensed under the MIT License. See License.txt in the project root for |
| | 3 | | // license information. |
| | 4 | |
|
| | 5 | | using System; |
| | 6 | |
|
| | 7 | | namespace Microsoft.Azure.KeyVault |
| | 8 | | { |
| | 9 | | internal static class UriExtensions |
| | 10 | | { |
| | 11 | | /// <summary> |
| | 12 | | /// Returns an authority string for URI that is guaranteed to contain |
| | 13 | | /// a port number. |
| | 14 | | /// </summary> |
| | 15 | | /// <param name="uri">The Uri from which to compute the authority</param> |
| | 16 | | /// <returns>The complete authority for the Uri</returns> |
| | 17 | | public static string FullAuthority(this Uri uri) |
| | 18 | | { |
| 568 | 19 | | string authority = uri.Authority; |
| | 20 | |
|
| 568 | 21 | | if (!authority.Contains(":") && uri.Port > 0) |
| | 22 | | { |
| | 23 | | // Append port for complete authority |
| 568 | 24 | | authority = string.Format("{0}:{1}", uri.Authority, uri.Port.ToString()); |
| | 25 | | } |
| | 26 | |
|
| 568 | 27 | | return authority; |
| | 28 | | } |
| | 29 | | } |
| | 30 | | } |