diff options
author | Feng Xiao <xiaofeng@google.com> | 2016-03-21 11:32:00 -0700 |
---|---|---|
committer | Feng Xiao <xiaofeng@google.com> | 2016-03-21 11:32:00 -0700 |
commit | 698fa8ee22a96ba35bcf1487bd372616cf67b565 (patch) | |
tree | f1b6a91f2409e97427b65ccf68e9ba1b53346632 | |
parent | 92091363cd830cf322ac8482154a9c2377a01add (diff) | |
parent | 4d98369f6d00dbdaa45ee2b91f1ec149a60ef905 (diff) | |
download | protobuf-698fa8ee22a96ba35bcf1487bd372616cf67b565.tar.gz protobuf-698fa8ee22a96ba35bcf1487bd372616cf67b565.tar.bz2 protobuf-698fa8ee22a96ba35bcf1487bd372616cf67b565.zip |
Merge pull request #1335 from pradeepg26/master
Allow custom URLs for Any in JsonFormat
-rw-r--r-- | java/util/src/main/java/com/google/protobuf/util/JsonFormat.java | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/java/util/src/main/java/com/google/protobuf/util/JsonFormat.java b/java/util/src/main/java/com/google/protobuf/util/JsonFormat.java index d13ff0ed..c9a28c9e 100644 --- a/java/util/src/main/java/com/google/protobuf/util/JsonFormat.java +++ b/java/util/src/main/java/com/google/protobuf/util/JsonFormat.java @@ -951,16 +951,15 @@ public class JsonFormat { } } - private static final String TYPE_URL_PREFIX = "type.googleapis.com"; - + private static String getTypeName(String typeUrl) throws InvalidProtocolBufferException { String[] parts = typeUrl.split("/"); - if (parts.length != 2 || !parts[0].equals(TYPE_URL_PREFIX)) { + if (parts.length == 1) { throw new InvalidProtocolBufferException( "Invalid type url found: " + typeUrl); } - return parts[1]; + return parts[parts.length - 1]; } private static class ParserImpl { |