Skip to content

Commit

Permalink
Merge pull request protocolbuffers#1335 from pradeepg26/master
Browse files Browse the repository at this point in the history
Allow custom URLs for Any in JsonFormat
  • Loading branch information
xfxyjwf committed Mar 21, 2016
2 parents 9209136 + 4d98369 commit 698fa8e
Showing 1 changed file with 3 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -951,16 +951,15 @@ private static String unsignedToString(final long value) {
}
}

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 {
Expand Down

0 comments on commit 698fa8e

Please sign in to comment.