forked from darylturner/node-netconf
-
Notifications
You must be signed in to change notification settings - Fork 9
Open
Description
Hi! 👋
Firstly, thanks for your work on this project! 🙂
Today I used patch-package to patch node-netconf@1.1.2 for the project I'm working on.
The issue: the package changes hyphens to underscores in netconf reply, which is not really neccessary.
Here is the diff that solved my problem:
diff --git a/node_modules/node-netconf/lib/netconf.js b/node_modules/node-netconf/lib/netconf.js
index e5a015c..9a2fb84 100644
--- a/node_modules/node-netconf/lib/netconf.js
+++ b/node_modules/node-netconf/lib/netconf.js
@@ -25,7 +25,6 @@ class Client extends EventEmitter {
this._parse = this._parse.bind(this);
this._sendHello = this._sendHello.bind(this);
this._createError = this._createError.bind(this);
- this._objectHelper = this._objectHelper.bind(this);
this.open = this.open.bind(this);
this.close = this.close.bind(this);
@@ -49,10 +48,7 @@ class Client extends EventEmitter {
this.parseOpts = {
trim: true,
explicitArray: false,
emptyTag: true,
ignoreAttrs: false,
- tagNameProcessors: [this._objectHelper],
- attrNameProcessors: [this._objectHelper],
valueProcessors: [xml2js.processors.parseNumbers],
attrValueProcessors: [xml2js.processors.parseNumbers]
};
@@ -151,9 +147,9 @@ class Client extends EventEmitter {
if (err) {
return next(err);
}
- if (message.hello.session_id > 0) {
+ if (message.hello["session-id"] > 0) {
self.remoteCapabilities = message.hello.capabilities.capability;
- self.sessionID = message.hello.session_id;
+ self.sessionID = message.hello["session-id"];
self.connected = true;
next(null);
} else {
@@ -254,7 +250,7 @@ class Client extends EventEmitter {
if (self.raw) {
message.raw = xml;
}
- if (message.rpc_reply.hasOwnProperty('rpc_error')) {
+ if (message["rpc-reply"].hasOwnProperty('rpc-error')) {
return callback(self._createError(JSON.stringify(message), 'rpcError'), null);
}
return callback(null, message);
@@ -300,19 +296,6 @@ class Client extends EventEmitter {
Error.captureStackTrace(err, self._createError);
return err;
}
-
- /**
- * Replaces characters that prevent dot-style object navigation
- * @function _objectHelper
- * @private
- * @param {string} name String to transform
- * @return {string} Transformed string
- */
- _objectHelper(name) {
- // Replaces characters that prevent dot-style object navigation.
- return name.replace(/-|:/g, '_');
- }
-
}
module.exports.Client = Client;This issue body was partially generated by patch-package.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels