Commit 698fa8ee authored by Feng Xiao's avatar Feng Xiao

Merge pull request #1335 from pradeepg26/master

Allow custom URLs for Any in JsonFormat
parents 92091363 4d98369f
...@@ -951,16 +951,15 @@ public class JsonFormat { ...@@ -951,16 +951,15 @@ public class JsonFormat {
} }
} }
private static final String TYPE_URL_PREFIX = "type.googleapis.com";
private static String getTypeName(String typeUrl) private static String getTypeName(String typeUrl)
throws InvalidProtocolBufferException { throws InvalidProtocolBufferException {
String[] parts = typeUrl.split("/"); String[] parts = typeUrl.split("/");
if (parts.length != 2 || !parts[0].equals(TYPE_URL_PREFIX)) { if (parts.length == 1) {
throw new InvalidProtocolBufferException( throw new InvalidProtocolBufferException(
"Invalid type url found: " + typeUrl); "Invalid type url found: " + typeUrl);
} }
return parts[1]; return parts[parts.length - 1];
} }
private static class ParserImpl { private static class ParserImpl {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment