-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added preserveWhitespace option to prevent trimming leading / trailin… #972
Conversation
…g whitespace from text and cdata values
My team uses this soap library and we ran into an issue where a soap service we consume has values that begin with a space and the space is intended to be preserved (part of an identifier). This change shouldn't break any existing behavior, rather it gives the ability to disable trimming whitespace for those who wish to turn that off. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add at least 1 test (see our section on How to submit a Pull Request in our CONTRIBUTING.md doc
lib/client.js
Outdated
@@ -126,6 +126,7 @@ Client.prototype._initializeOptions = function(options) { | |||
this.streamAllowed = options.stream; | |||
this.wsdl.options.attributesKey = options.attributesKey || 'attributes'; | |||
this.wsdl.options.envelopeKey = options.envelopeKey || 'soap'; | |||
this.wsdl.options.preserveWhitespace = options.preserveWhitespace || false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could you please use !!
to convert into boolean (this.wsdl.options.preserverWhitespace = !!options.preserveWhitespace
)?
package.json
Outdated
@@ -1,6 +1,6 @@ | |||
{ | |||
"name": "soap", | |||
"version": "0.21.0", | |||
"version": "0.22.0", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please revert the version change - we'd like to change it ourselves when we create the next release (which will be really soon, promised 👍 )
lib/wsdl.js
Outdated
@@ -1403,7 +1403,9 @@ WSDL.prototype.xmlToObject = function(xml, callback) { | |||
}; | |||
|
|||
p.oncdata = function (text) { | |||
text = trim(text); | |||
if (!self.options || !self.options.preserveWhitespace) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess it's save to check for self.options.preserveWhitespace
only as the options should be set up anyways(?)
please rebase your PR with the latest master - I updated our |
@herom Thanks for the feedback. I think I've addressed it all, but let me know. |
@samuelms1 awesome! thanks a lot for you contribution 💯 Could you please do me a last favour and add a test which guarantees that the whitespaces get cut if the |
@herom Good idea. I'll add that in now. |
…ling whitespace is removed by default
Awesome! 💯 Thanks a ton @samuelms1 👍 😺 |
…g whitespace from text and cdata values