Fix UserAgent.encode

This commit is contained in:
Kagami Hiiragi 2015-01-11 20:28:12 +03:00
parent 001f5b16df
commit e40a40abd0
2 changed files with 5 additions and 2 deletions

View File

@ -56,8 +56,8 @@ var encode = exports.encode = function(software) {
var ua = software.map(function(soft) {
var version = soft.version || "0.0.0";
var str = soft.name + ":" + version;
if (str.comments) {
str += "(" + comments + ")";
if (soft.comments) {
str += "(" + soft.comments + ")";
}
return str;
}).join("/");

View File

@ -402,6 +402,9 @@ describe("High-level classes", function() {
expect(res.software).to.deep.equal([pybm]);
expect(res.length).to.equal(21);
expect(res.rest.toString("hex")).to.equal("");
ua = UserAgent.encode([{name: "test", "comments": "linux"}]);
expect(var_str.decode(ua).str).to.equal("/test:0.0.0(linux)/");
});
it("should encode bitmessage's user agent", function() {