@amimpact/willy-utils 4.5.0 → 4.5.2

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": "@amimpact/willy-utils",
3
- "version": "4.5.0",
3
+ "version": "4.5.2",
4
4
  "description": "Javascript utils",
5
5
  "scripts": {
6
6
  "publish:prerelease": "npm version prerelease --preid beta && npm publish --tag beta",
package/src/form.ts CHANGED
@@ -1,3 +1,16 @@
1
+ /**
2
+ * Verwijdert de Froala footer uit de HTML string
3
+ * @param {string} htmlString
4
+ * @return {string} HTML string zonder de Froala footer
5
+ */
6
+ const removeFroalaFooter = (htmlString) => {
7
+ if (typeof htmlString !== 'string') {
8
+ return htmlString;
9
+ }
10
+
11
+ return htmlString.replace(/<p[^>]*data-f-id="pbf"[^>]*>[\s\S]*?<\/p>/, '');
12
+ };
13
+
1
14
  /**
2
15
  * Creeert een FormData object vanuit een object
3
16
  * https://gist.github.com/ghinda/8442a57f22099bdb2e34#gistcomment-2719686
@@ -63,7 +76,7 @@ export const convertObjectToFormData = (
63
76
  const val = model[propertyName];
64
77
  const formDataValue = typeof val === 'boolean' ? (val ? '1' : '0') : val;
65
78
 
66
- formData.append(formKey, formDataValue.toString());
79
+ formData.append(formKey, removeFroalaFooter(formDataValue.toString()));
67
80
  }
68
81
  }
69
82
 
package/src/misc.ts CHANGED
@@ -166,6 +166,10 @@ export const isEmpty = (value): boolean => {
166
166
  return !Object.keys(value).length;
167
167
  }
168
168
 
169
+ if (Number.isNaN(value)) {
170
+ return false;
171
+ }
172
+
169
173
  return !value;
170
174
  };
171
175