Skip to content

Commit

Permalink
Merge pull request #46 from Trakkasure/bugfix/multi-line-attribute-va…
Browse files Browse the repository at this point in the history
…lues-fail

Fixed issue when an attribute value has multiple lines
  • Loading branch information
Trakkasure authored Aug 24, 2017
2 parents 2073b01 + df31058 commit a1fd5f9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "mikronode",
"description": "Mikrotik API implemented in Node",
"version": "2.3.0",
"version": "2.3.1",
"author": "Brandon Myers <[email protected]>",
"scripts": {
"build": "webpack --color --progress",
Expand Down Expand Up @@ -48,10 +48,10 @@
"webpack-dev-server": "^1.15.0"
},
"dependencies": {
"rxjs": "^5.0.0-beta.10"
"rxjs": "^5.3.0"
},
"main": "dist/mikronode.js",
"engines": {
"node": ">= 4"
"node": ">= 6"
}
}
7 changes: 5 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -257,10 +257,13 @@ class SocketStream {
this.sentence$=new Subject();
// Each raw sentence from the stream passes through this parser.
this.parsed$=this.sentence$
.map(o=>o.join('\n')) // Make array string.
.map(o=>o.map(x=>x.split("\r").join("\\r").split("\n").join("\\n")).join('\n')) // Make array string.
.do(d=>this.debug>=DEBUG.SILLY&&console.log("Data to parse:",d))
.map(d=>{var s=parser.parse(d);s.host=this.host;return s;})
.flatMap(d=>Observable.from(d)) // break off observable from parse stream.
.flatMap(d=>{
Object.keys(d).forEach(k=>{if(typeof d[k]==="string")d[k]=d[k].split("\\r").join("\r").split("\\n").join("\n")});
return Observable.from(d);
}) // break off observable from parse stream.
.share(); // parse the string.

// When we receive data, it is pushed into the stream defined below.
Expand Down

0 comments on commit a1fd5f9

Please sign in to comment.