@smartsoft001/crud-shell-app-services 2.107.0 → 2.109.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/index.js +28 -1
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -65,6 +65,31 @@ var PasswordService = class _PasswordService {
|
|
|
65
65
|
}
|
|
66
66
|
};
|
|
67
67
|
|
|
68
|
+
// packages/shared/utils/src/lib/services/remove-html/remove-html.service.ts
|
|
69
|
+
var RemoveHtmlService = class {
|
|
70
|
+
/**
|
|
71
|
+
* Remove HTML tags and decode HTML entities from text
|
|
72
|
+
* - Removes HTML tags
|
|
73
|
+
* - Decodes common named entities ( , ", etc.)
|
|
74
|
+
* - Decodes numeric entities ({ or «)
|
|
75
|
+
* - Removes any remaining unrecognized entities
|
|
76
|
+
*/
|
|
77
|
+
static create(val) {
|
|
78
|
+
if (!val) {
|
|
79
|
+
return "";
|
|
80
|
+
}
|
|
81
|
+
let result = val;
|
|
82
|
+
result = result.replace(/<[^>]*(>|$)/g, "");
|
|
83
|
+
result = result.replace(/ /g, " ").replace(/"/g, '"').replace(/'/g, "'").replace(/</g, "<").replace(/>/g, ">").replace(/&/g, "&").replace(/„/g, "\u201E").replace(/”/g, '"').replace(/“/g, '"').replace(/«/g, "\xAB").replace(/»/g, "\xBB").replace(/‌/g, "");
|
|
84
|
+
result = result.replace(/&#(\d+);/g, (match, dec) => String.fromCharCode(dec)).replace(
|
|
85
|
+
/&#x([0-9a-f]+);/gi,
|
|
86
|
+
(match, hex) => String.fromCharCode(parseInt(hex, 16))
|
|
87
|
+
);
|
|
88
|
+
result = result.replace(/&[a-z]+;/gi, "");
|
|
89
|
+
return result;
|
|
90
|
+
}
|
|
91
|
+
};
|
|
92
|
+
|
|
68
93
|
// packages/shared/utils/src/lib/services/slug/slug.service.ts
|
|
69
94
|
var SlugService = class _SlugService {
|
|
70
95
|
static {
|
|
@@ -91,6 +116,7 @@ var SlugService = class _SlugService {
|
|
|
91
116
|
}
|
|
92
117
|
/**
|
|
93
118
|
* Convert text to URL-friendly slug
|
|
119
|
+
* - Removes HTML tags and entities
|
|
94
120
|
* - Replaces Polish characters with English equivalents
|
|
95
121
|
* - Converts to lowercase
|
|
96
122
|
* - Replaces spaces and special characters with hyphens
|
|
@@ -101,7 +127,8 @@ var SlugService = class _SlugService {
|
|
|
101
127
|
if (!text) {
|
|
102
128
|
return "";
|
|
103
129
|
}
|
|
104
|
-
let slug =
|
|
130
|
+
let slug = RemoveHtmlService.create(text);
|
|
131
|
+
slug = slug.split("").map((char) => _SlugService.polishToEnglishMap[char] || char).join("");
|
|
105
132
|
slug = slug.toLowerCase();
|
|
106
133
|
slug = slug.replace(/[^a-z0-9]+/g, "-");
|
|
107
134
|
slug = slug.replace(/-+/g, "-");
|