Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions lib/action.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,16 @@ Action.prototype.serialize = function() {
var keys = Object.keys(this.data);
var packet = '';
for(var i = 0, key; key = keys[i]; i++) {
//ensure first char is uppercase (support json -> AMI casing)
packet += key[0].toUpperCase();
packet += key.substr(1);
packet += ': ';
packet += this.data[key];
packet += NEWLINE;
//got array to support multiple headers with same name
var values = Array.isArray(this.data[key]) ? this.data[key] : [this.data[key]];
for (var j = 0; j < values.length; j++) {
//ensure first char is uppercase (support json -> AMI casing)
packet += key[0].toUpperCase();
packet += key.substr(1);
packet += ': ';
packet += values[j];
packet += NEWLINE;
}
}
packet += NEWLINE;
return packet;
Expand Down
8 changes: 5 additions & 3 deletions lib/parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,11 @@ Parser.prototype.parse = function(newPacket) {
break;
case ':':
//skip space after colon
this.setState(Parser.VALUE);
i++;
break;
if (this.isState(Parser.KEY)) {
this.setState(Parser.VALUE);
i++;
break;
}
default:
if(this.isState(Parser.FIRST_KEY) || this.isState(Parser.FIRST_NL)) {
//make keys javascript casing
Expand Down
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"author": "Brian M. Carlson <brian@enginode.com> (enginode.com)",
"name": "ami",
"author": "Thiago Costa <admin@rootbsd.info>",
"name": "@thiagodk/ami",
"description": "AMI (Asterisk Manager Interface) client",
"version": "0.0.2",
"version": "0.0.3",
"repository": {
"type": "git",
"url": "git://github.com/brianc/node-ami.git"
"url": "git://github.com/thiagodk/node-ami"
},
"main": "lib/",
"scripts": {
Expand Down