@etsoo/shared 1.2.66 → 1.2.68
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/README.md +2 -0
- package/__tests__/Utils.ts +20 -0
- package/lib/cjs/Utils.d.ts +12 -0
- package/lib/cjs/Utils.js +18 -0
- package/lib/mjs/Utils.d.ts +12 -0
- package/lib/mjs/Utils.js +18 -0
- package/package.json +2 -2
- package/src/Utils.ts +18 -0
package/README.md
CHANGED
|
@@ -306,6 +306,8 @@ String and other related utilities
|
|
|
306
306
|
| getDataChanges | Get data changed fields with input data updated |
|
|
307
307
|
| getNestedValue | Get nested value from object |
|
|
308
308
|
| getTimeZone | Get time zone |
|
|
309
|
+
| hasHtmlEntity | Check the input string contains HTML entity or not |
|
|
310
|
+
| hasHtmlTag | Check the input string contains HTML tag or not |
|
|
309
311
|
| hideData | Hide data |
|
|
310
312
|
| hideEmail | Hide email data |
|
|
311
313
|
| isDigits | Is digits string |
|
package/__tests__/Utils.ts
CHANGED
|
@@ -198,6 +198,26 @@ test("Tests for formatString", () => {
|
|
|
198
198
|
expect(template.format("aa", "bb")).toBe(result);
|
|
199
199
|
});
|
|
200
200
|
|
|
201
|
+
test("Tests for hasHtmlEntity", () => {
|
|
202
|
+
expect(Utils.hasHtmlEntity(" ")).toBeFalsy();
|
|
203
|
+
expect(Utils.hasHtmlEntity(" ")).toBeTruthy();
|
|
204
|
+
expect(Utils.hasHtmlEntity("< >")).toBeTruthy();
|
|
205
|
+
expect(Utils.hasHtmlEntity("&180;")).toBeFalsy();
|
|
206
|
+
expect(Utils.hasHtmlEntity("&160;")).toBeTruthy();
|
|
207
|
+
expect(
|
|
208
|
+
Utils.hasHtmlEntity(
|
|
209
|
+
"<p>Hello, world! This is <b>BOLD</b>.</p>"
|
|
210
|
+
)
|
|
211
|
+
).toBeTruthy();
|
|
212
|
+
});
|
|
213
|
+
|
|
214
|
+
test("Tests for hasHtmlTag", () => {
|
|
215
|
+
expect(Utils.hasHtmlTag("<>")).toBeFalsy();
|
|
216
|
+
expect(Utils.hasHtmlTag("<div>")).toBeTruthy();
|
|
217
|
+
expect(Utils.hasHtmlTag("</h1>")).toBeTruthy();
|
|
218
|
+
expect(Utils.hasHtmlTag("<br>")).toBeTruthy();
|
|
219
|
+
});
|
|
220
|
+
|
|
201
221
|
test("Tests for hideData", () => {
|
|
202
222
|
expect("xz@etsoo.com".hideEmail()).toBe("x***@etsoo.com");
|
|
203
223
|
expect("info@etsoo.com".hideEmail()).toBe("in***@etsoo.com");
|
package/lib/cjs/Utils.d.ts
CHANGED
|
@@ -180,6 +180,18 @@ export declare namespace Utils {
|
|
|
180
180
|
* @returns Timezone
|
|
181
181
|
*/
|
|
182
182
|
export const getTimeZone: (tz?: string) => string;
|
|
183
|
+
/**
|
|
184
|
+
* Check the input string contains HTML entity or not
|
|
185
|
+
* @param input Input string
|
|
186
|
+
* @returns Result
|
|
187
|
+
*/
|
|
188
|
+
export function hasHtmlEntity(input: string): boolean;
|
|
189
|
+
/**
|
|
190
|
+
* Check the input string contains HTML tag or not
|
|
191
|
+
* @param input Input string
|
|
192
|
+
* @returns Result
|
|
193
|
+
*/
|
|
194
|
+
export function hasHtmlTag(input: string): boolean;
|
|
183
195
|
/**
|
|
184
196
|
* Is digits string
|
|
185
197
|
* @param input Input string
|
package/lib/cjs/Utils.js
CHANGED
|
@@ -357,6 +357,24 @@ var Utils;
|
|
|
357
357
|
// Default timezone
|
|
358
358
|
return tz ?? "UTC";
|
|
359
359
|
};
|
|
360
|
+
/**
|
|
361
|
+
* Check the input string contains HTML entity or not
|
|
362
|
+
* @param input Input string
|
|
363
|
+
* @returns Result
|
|
364
|
+
*/
|
|
365
|
+
function hasHtmlEntity(input) {
|
|
366
|
+
return /&(lt|gt|nbsp|60|62|160|#x3C|#x3E|#xA0);/i.test(input);
|
|
367
|
+
}
|
|
368
|
+
Utils.hasHtmlEntity = hasHtmlEntity;
|
|
369
|
+
/**
|
|
370
|
+
* Check the input string contains HTML tag or not
|
|
371
|
+
* @param input Input string
|
|
372
|
+
* @returns Result
|
|
373
|
+
*/
|
|
374
|
+
function hasHtmlTag(input) {
|
|
375
|
+
return /<\/?[a-z]+[^<>]*>/i.test(input);
|
|
376
|
+
}
|
|
377
|
+
Utils.hasHtmlTag = hasHtmlTag;
|
|
360
378
|
/**
|
|
361
379
|
* Is digits string
|
|
362
380
|
* @param input Input string
|
package/lib/mjs/Utils.d.ts
CHANGED
|
@@ -180,6 +180,18 @@ export declare namespace Utils {
|
|
|
180
180
|
* @returns Timezone
|
|
181
181
|
*/
|
|
182
182
|
export const getTimeZone: (tz?: string) => string;
|
|
183
|
+
/**
|
|
184
|
+
* Check the input string contains HTML entity or not
|
|
185
|
+
* @param input Input string
|
|
186
|
+
* @returns Result
|
|
187
|
+
*/
|
|
188
|
+
export function hasHtmlEntity(input: string): boolean;
|
|
189
|
+
/**
|
|
190
|
+
* Check the input string contains HTML tag or not
|
|
191
|
+
* @param input Input string
|
|
192
|
+
* @returns Result
|
|
193
|
+
*/
|
|
194
|
+
export function hasHtmlTag(input: string): boolean;
|
|
183
195
|
/**
|
|
184
196
|
* Is digits string
|
|
185
197
|
* @param input Input string
|
package/lib/mjs/Utils.js
CHANGED
|
@@ -351,6 +351,24 @@ export var Utils;
|
|
|
351
351
|
// Default timezone
|
|
352
352
|
return tz ?? "UTC";
|
|
353
353
|
};
|
|
354
|
+
/**
|
|
355
|
+
* Check the input string contains HTML entity or not
|
|
356
|
+
* @param input Input string
|
|
357
|
+
* @returns Result
|
|
358
|
+
*/
|
|
359
|
+
function hasHtmlEntity(input) {
|
|
360
|
+
return /&(lt|gt|nbsp|60|62|160|#x3C|#x3E|#xA0);/i.test(input);
|
|
361
|
+
}
|
|
362
|
+
Utils.hasHtmlEntity = hasHtmlEntity;
|
|
363
|
+
/**
|
|
364
|
+
* Check the input string contains HTML tag or not
|
|
365
|
+
* @param input Input string
|
|
366
|
+
* @returns Result
|
|
367
|
+
*/
|
|
368
|
+
function hasHtmlTag(input) {
|
|
369
|
+
return /<\/?[a-z]+[^<>]*>/i.test(input);
|
|
370
|
+
}
|
|
371
|
+
Utils.hasHtmlTag = hasHtmlTag;
|
|
354
372
|
/**
|
|
355
373
|
* Is digits string
|
|
356
374
|
* @param input Input string
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@etsoo/shared",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.68",
|
|
4
4
|
"description": "TypeScript shared utilities and functions",
|
|
5
5
|
"main": "lib/cjs/index.js",
|
|
6
6
|
"module": "lib/mjs/index.js",
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"@types/lodash.isequal": "^4.5.8",
|
|
40
40
|
"@vitejs/plugin-react": "^4.3.4",
|
|
41
41
|
"jsdom": "^26.0.0",
|
|
42
|
-
"typescript": "^5.8.
|
|
42
|
+
"typescript": "^5.8.3",
|
|
43
43
|
"vitest": "^3.1.1"
|
|
44
44
|
},
|
|
45
45
|
"dependencies": {
|
package/src/Utils.ts
CHANGED
|
@@ -534,6 +534,24 @@ export namespace Utils {
|
|
|
534
534
|
return tz ?? "UTC";
|
|
535
535
|
};
|
|
536
536
|
|
|
537
|
+
/**
|
|
538
|
+
* Check the input string contains HTML entity or not
|
|
539
|
+
* @param input Input string
|
|
540
|
+
* @returns Result
|
|
541
|
+
*/
|
|
542
|
+
export function hasHtmlEntity(input: string) {
|
|
543
|
+
return /&(lt|gt|nbsp|60|62|160|#x3C|#x3E|#xA0);/i.test(input);
|
|
544
|
+
}
|
|
545
|
+
|
|
546
|
+
/**
|
|
547
|
+
* Check the input string contains HTML tag or not
|
|
548
|
+
* @param input Input string
|
|
549
|
+
* @returns Result
|
|
550
|
+
*/
|
|
551
|
+
export function hasHtmlTag(input: string) {
|
|
552
|
+
return /<\/?[a-z]+[^<>]*>/i.test(input);
|
|
553
|
+
}
|
|
554
|
+
|
|
537
555
|
/**
|
|
538
556
|
* Is digits string
|
|
539
557
|
* @param input Input string
|