Skip to content
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

Saving node description property to the library #2490

Merged
merged 2 commits into from May 22, 2020
Merged

Saving node description property to the library #2490

merged 2 commits into from May 22, 2020

Conversation

kazuhitoyokoi
Copy link
Member

  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)

Proposed changes

To reuse node description in function node via the library, I added the function which saves the node description with other metadata and JavaScript code in a function node.

Checklist

  • I have read the contribution guidelines
  • For non-bugfix PRs, I have discussed this change on the forum/slack team.
  • I have run grunt to verify the unit tests pass
  • I have added suitable unit tests to cover the new/changed functionality

@coveralls
Copy link

coveralls commented Mar 2, 2020

Coverage Status

Coverage increased (+0.06%) to 77.504% when pulling 08ef9ee on kazuhitoyokoi:dev-addinfo2lib into c9ad5be on node-red:dev.

@knolleary
Copy link
Member

Thanks @kazuhitoyokoi

To summarise, this fix works by replacing any newline character, \n with the literal string "\n" when saving to the library. And when loading from the library, replacing any literal string "\n" with the newline character.

This does introduce an edge case where a node's info contains the string \n already. For example:

This node saves the data to c:\node-red\new-data.csv

When restored from the library, it would appear as:

This node saves the data to c:
ode-red
ew-data.csv

Can we add an extra step to replace "\n" with "\\n" before we replace \n with "\n"?

@kazuhitoyokoi
Copy link
Member Author

@knolleary Thank you for the information. I did not care about backslash characters. I modified code to add the handling for backslash.

@knolleary knolleary added this to the 1.1 milestone May 21, 2020
@knolleary knolleary merged commit 22e7ddc into node-red:dev May 22, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants