Last active
October 3, 2018 12:18
-
-
Save JamesJJ/0f65fdfeb402287c955c3f50d51bdfd2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
public class Program | |
{ | |
public static void Main() | |
{ | |
// example values ... | |
var uriStringFromDgm = "http://blob-cn.htcvive.com/abc/123qwerty"; | |
var uriStringFromNetMethodTargetField = "https://fast-cdn.wow.com:11443/some_prefix"; | |
// Use UriBuilder | |
UriBuilder uriDGM = new UriBuilder(uriStringFromDgm); | |
UriBuilder uriDownload = new UriBuilder(uriStringFromNetMethodTargetField); | |
// Schema, Host, Port, Path_Prefix from NetMethod | |
// Only Path_Suffix from DGM | |
if (uriDownload.Path.Equals("/")) { | |
uriDownload.Path = uriDGM.Path; | |
} else { | |
uriDownload.Path += uriDGM.Path; | |
} | |
// The URL to use for download is now ready in "uriDownload" | |
Console.WriteLine(uriDownload.ToString()); | |
// https://fast-cdn.wow.com:11443/some_prefix/abc/123qwerty | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
In case this situation:
var uriStringFromNetMethodTargetField = "https://fast-cdn.wow.com:11443/some_prefix/";
I'll do:
else { uriDownload.Path = $"{uriDownload.Path.TrimEnd('/')}/{uriDGM.Path}"; }