Skip to content

Commit

Permalink
Merge pull request #50 from Trakkasure/bugfix/query-word-has-broken
Browse files Browse the repository at this point in the history
Resolved #47. Print requires pre-formatted.
  • Loading branch information
Trakkasure authored Aug 26, 2017
2 parents 68423b1 + 4cc3a97 commit e4b2f5a
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 5 deletions.
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,8 @@
node_modules
dist
examples
test
.vscode
.jshintrc
jsconfig.json
webpack.config.babel.js
2 changes: 1 addition & 1 deletion 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.2",
"version": "2.3.3",
"author": "Brandon Myers <[email protected]>",
"scripts": {
"build": "webpack --color --progress",
Expand Down
5 changes: 2 additions & 3 deletions src/Util.js
Original file line number Diff line number Diff line change
Expand Up @@ -177,10 +177,9 @@ function getUnwrappedPromise() {
}

function objToAPIParams(obj,type) {
const prefix=type==='print'?'?':'=';
const t=RegExp("[a-zA-Z]");
const prefix=type==='print'?'':'=';
return Object.keys(obj)
.map(k=>obj[k]?`${t.test(k[0])?prefix:""}${k}=${obj[k]}`:`${t.test(k[0])?prefix:""}${k}`);
.map(k=>obj[k]?`${prefix}${k}=${obj[k]}`:`${prefix}${k}`);
}

function resultsToObj(r) {
Expand Down
2 changes: 1 addition & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@ class SocketStream {
write(data,args) {
if (args && typeof(args)===typeof({})) {
this.debug>=DEBUG.SILLY&&console.log("Converting obj to args",args);
data=data.concat(objToAPIParams(args,data[0].split('/').pop()));
data=data.concat(Array.isArray(args)?args:objToAPIParams(args,data[0].split('/').pop()));
}
this.debug>=DEBUG.DEBUG&&console.log('SocketStream::write:',[data]);
if (!this.socket||!(this.status&(CONNECTION.CONNECTED|CONNECTION.CONNECTING))) {
Expand Down

0 comments on commit e4b2f5a

Please sign in to comment.