Add MVP link fragment Clipboard Fusion macro
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; | |
using System.Web; | |
public static class ClipboardFusionHelper | |
{ | |
// Put your ID below | |
public static string ID = "DOP-MVP-5001511"; | |
public static string[] docsAndLearnChampionDomains = { | |
"docs.microsoft.com", | |
"learn.microsoft.com", | |
"social.technet.microsoft.com", | |
"azure.microsoft.com", | |
"techcommunity.microsoft.com", | |
"social.msdn.microsoft.com", | |
"devblogs.microsoft.com", | |
"developer.microsoft.com", | |
"channel9.msdn.com", | |
"gallery.technet.microsoft.com", | |
"cloudblogs.microsoft.com", | |
"technet.microsoft.com", | |
"docs.azure.cn", | |
"www.azure.cn", | |
"msdn.microsoft.com", | |
"blogs.msdn.microsoft.com", | |
"blogs.technet.microsoft.com", | |
"microsoft.com/handsonlabs" | |
}; | |
public static string ProcessText(string text) | |
{ | |
try | |
{ | |
Uri x = new Uri(text, UriKind.Absolute); | |
bool match = false; | |
foreach (var domain in docsAndLearnChampionDomains) | |
{ | |
var y = new Uri("https://" + domain, UriKind.Absolute); | |
if (string.Equals(x.Host, y.Host, StringComparison.OrdinalIgnoreCase) | |
&& x.AbsolutePath.StartsWith(y.AbsolutePath, StringComparison.OrdinalIgnoreCase)) | |
{ | |
match = true; | |
break; | |
} | |
} | |
if (match) | |
{ | |
var uriBuilder = new UriBuilder(x); | |
var query = HttpUtility.ParseQueryString(uriBuilder.Query); | |
query["WT.mc_id"] = ID; | |
uriBuilder.Query = query.ToString(); | |
return uriBuilder.Uri.AbsoluteUri; | |
} | |
} | |
catch (UriFormatException) { } | |
return text; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment