phylotree 1.4.2 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "phylotree",
3
- "version": "1.4.2",
3
+ "version": "2.0.0",
4
4
  "main": "dist/phylotree.js",
5
5
  "unpkg": "dist/phylotree.js",
6
6
  "jsdelivr": "dist/phylotree.js",
@@ -251,14 +251,15 @@ export function getNewick(annotator, root) {
251
251
  element_array.push(")");
252
252
  }
253
253
 
254
- if(n.data.name != 'root') {
255
- const node_label = n.data.name.replace("'", "''");
254
+ if(n.data.name !== 'root') {
255
+ const node_label = n.data.name.replaceAll("'", "''");
256
256
 
257
- // Escape the entire string if it contains any whitespace.
258
- if (/\w/.test(node_label)) {
257
+ // Surround the entire string with single quotes if it contains any
258
+ // non-alphanumeric characters.
259
+ if (/\W/.test(node_label)) {
259
260
  element_array.push("'" + node_label + "'");
260
261
  } else {
261
- element_array.push(n.data.name);
262
+ element_array.push(node_label);
262
263
  }
263
264
  }
264
265
  element_array.push(annotator(n));