Skip to content

handle 'type.googleapis.com/' string #850

@FoghostCn

Description

@FoghostCn

protobuf.js version: 6.8.0

in google's any.proto file I find this document:

The pack methods provided by protobuf library will by default use
'type.googleapis.com/full.type.name' as the type URL and the unpack
methods only use the fully qualified type name after the last '/'
in the type URL, for example "foo.bar.com/x/y.z" will yield type
name "y.z".

and I have seen your code about any type

wrappers[".google.protobuf.Any"] = {
    fromObject: function(object) {
        // unwrap value type if mapped
        if (object && object["@type"]) {
            var type = this.lookup(object["@type"]);
            ........
        }
        return this.fromObject(object);
    },
    toObject: function(message, options) {
        // decode value if requested and unmapped
        if (options && options.json && message.type_url && message.value) {
            var type = this.lookup(message.type_url);
        .......
        return this.toObject(message, options);
    }
};

fromObject and toObject method didn't handle type.googleapis.com/ string

actually Msg.decode(buffer).toJSON() didn't auto decode Any type with type_url =type.googleapis.com/myMsg but can auto decode .myMsg

did I missing something?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions