We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 70f0bcb commit 6e5ad19Copy full SHA for 6e5ad19
1 file changed
lib/js2xmlparser.js
@@ -26,6 +26,9 @@
26
if (typeof root !== "string") {
27
throw new Error("root element must be a string");
28
}
29
+ else if (root === "") {
30
+ throw new Error("root element cannot be empty");
31
+ }
32
33
// Error checking and variable initialization for options
34
if (typeof options === "object" && options !== null) {
@@ -106,6 +109,10 @@
106
109
throw new Error("data must be an object or a string");
107
110
108
111
112
+ if (Object.prototype.toString.call(data) === "[object Array]") {
113
+ throw new Error("data cannot be an array");
114
115
+
116
if (typeof data === "string") {
117
data = JSON.parse(data);
118
0 commit comments