-
Notifications
You must be signed in to change notification settings - Fork 36
/
Copy pathUriHelper.cs
45 lines (41 loc) · 1.32 KB
/
UriHelper.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
39
40
41
42
43
44
45
using System;
using JetBrains.Annotations;
namespace CodeJam
{
/// <summary>
/// Helper methods for <see cref="Uri"/> class.
/// </summary>
[PublicAPI]
public static class UriHelper
{
/// <summary>
/// Combine two uris.
/// </summary>
/// <param name="baseUri">Base uri</param>
/// <param name="relativeUri">Relative uri</param>
/// <returns>Combined uri.</returns>
[Pure, System.Diagnostics.Contracts.Pure]
public static Uri Combine(this Uri baseUri, Uri relativeUri) => new(baseUri, relativeUri);
/// <summary>
/// Combine two uris.
/// </summary>
/// <param name="baseUri">Base uri</param>
/// <param name="relativeUri">Relative uri</param>
/// <returns>Combined uri.</returns>
[Pure, System.Diagnostics.Contracts.Pure]
public static Uri Combine(this Uri baseUri, string relativeUri) => new(baseUri, relativeUri);
/// <summary>
/// Combine two uris.
/// </summary>
/// <param name="baseUri">Base uri</param>
/// <param name="relativeUri">Relative uri</param>
/// <returns>Combined uri.</returns>
[Pure, System.Diagnostics.Contracts.Pure]
public static Uri Combine(string baseUri, string relativeUri)
{
var baseParsed = new Uri(baseUri);
Code.AssertArgument(!baseParsed.IsAbsoluteUri, nameof(baseUri), "Base uri must be absolute");
return new Uri(baseParsed, relativeUri);
}
}
}