Skip to content

Instantly share code, notes, and snippets.

@mgaffigan
Last active December 4, 2017 19:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mgaffigan/5978c15f65dd2453c7302d9ef07922d6 to your computer and use it in GitHub Desktop.
Save mgaffigan/5978c15f65dd2453c7302d9ef07922d6 to your computer and use it in GitHub Desktop.
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