diff --git a/Octokit/Http/SimpleJsonSerializer.cs b/Octokit/Http/SimpleJsonSerializer.cs index c32c5544..80f9464a 100644 --- a/Octokit/Http/SimpleJsonSerializer.cs +++ b/Octokit/Http/SimpleJsonSerializer.cs @@ -64,6 +64,15 @@ namespace Octokit.Internal var stringValue = value as string; if (stringValue != null) { + if (ReflectionUtils.IsUri(type)) + { + Uri result; + if (Uri.TryCreate(stringValue, UriKind.RelativeOrAbsolute, out result)) + { + return result; + } + } + if (ReflectionUtils.GetTypeInfo(type).IsEnum) { return Enum.Parse(type, stringValue, ignoreCase: true); diff --git a/Octokit/SimpleJson.cs b/Octokit/SimpleJson.cs index 613894b7..fdb57d48 100644 --- a/Octokit/SimpleJson.cs +++ b/Octokit/SimpleJson.cs @@ -1667,6 +1667,11 @@ namespace Octokit return GetTypeInfo(type).IsGenericType && type.GetGenericTypeDefinition() == typeof(Nullable<>); } + public static bool IsUri(Type type) + { + return GetTypeInfo(type) == GetTypeInfo(typeof(Uri)); + } + public static object ToNullableType(object obj, Type nullableType) { return obj == null ? null : Convert.ChangeType(obj, Nullable.GetUnderlyingType(nullableType), CultureInfo.InvariantCulture);