Last active
December 4, 2017 19:21
-
-
Save mgaffigan/5978c15f65dd2453c7302d9ef07922d6 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; | |
using System.Collections.Generic; | |
using System.Diagnostics; | |
using System.Linq; | |
using System.Net; | |
using System.Text; | |
using System.Threading.Tasks; | |
namespace StripJabberTelUri | |
{ | |
class Program | |
{ | |
// Update Computer\HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Cisco.Jabber.ITP.telhandler\shell\open\command | |
// to: "C:\path\to\StripJabberTelUri.exe" "C:\Program Files (x86)\Cisco Systems\Cisco Jabber\CiscoJabber.exe" -URI %1 | |
static void Main(string[] args) | |
{ | |
var command = args[0]; | |
var newArgs = string.Join(" ", args.Skip(1).Select(TransformArg)); | |
Process.Start(command, newArgs); | |
} | |
private static string TransformArg(string arg) | |
{ | |
if (!arg.ToLowerInvariant().StartsWith("tel:")) | |
{ | |
return arg; | |
} | |
var decoded = WebUtility.UrlDecode(new Uri(arg).PathAndQuery); | |
var newArg = new StringBuilder(decoded.Length + 4); | |
newArg.Append("tel:"); | |
foreach (var c in decoded) | |
{ | |
if ("0123456789x".Contains(c)) | |
{ | |
newArg.Append(c); | |
} | |
} | |
return newArg.ToString(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment