@smartsoft001/trans-shell-nestjs 2.105.0 → 2.107.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
|
@@ -125,6 +125,31 @@ var PasswordService = class _PasswordService {
|
|
|
125
125
|
}
|
|
126
126
|
};
|
|
127
127
|
|
|
128
|
+
// packages/shared/utils/src/lib/services/remove-html/remove-html.service.ts
|
|
129
|
+
var RemoveHtmlService = class {
|
|
130
|
+
/**
|
|
131
|
+
* Remove HTML tags and decode HTML entities from text
|
|
132
|
+
* - Removes HTML tags
|
|
133
|
+
* - Decodes common named entities ( , ", etc.)
|
|
134
|
+
* - Decodes numeric entities ({ or «)
|
|
135
|
+
* - Removes any remaining unrecognized entities
|
|
136
|
+
*/
|
|
137
|
+
static create(val) {
|
|
138
|
+
if (!val) {
|
|
139
|
+
return "";
|
|
140
|
+
}
|
|
141
|
+
let result = val;
|
|
142
|
+
result = result.replace(/<[^>]*(>|$)/g, "");
|
|
143
|
+
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, "");
|
|
144
|
+
result = result.replace(/&#(\d+);/g, (match, dec) => String.fromCharCode(dec)).replace(
|
|
145
|
+
/&#x([0-9a-f]+);/gi,
|
|
146
|
+
(match, hex) => String.fromCharCode(parseInt(hex, 16))
|
|
147
|
+
);
|
|
148
|
+
result = result.replace(/&[a-z]+;/gi, "");
|
|
149
|
+
return result;
|
|
150
|
+
}
|
|
151
|
+
};
|
|
152
|
+
|
|
128
153
|
// packages/shared/utils/src/lib/services/slug/slug.service.ts
|
|
129
154
|
var SlugService = class _SlugService {
|
|
130
155
|
static {
|
|
@@ -151,6 +176,7 @@ var SlugService = class _SlugService {
|
|
|
151
176
|
}
|
|
152
177
|
/**
|
|
153
178
|
* Convert text to URL-friendly slug
|
|
179
|
+
* - Removes HTML tags and entities
|
|
154
180
|
* - Replaces Polish characters with English equivalents
|
|
155
181
|
* - Converts to lowercase
|
|
156
182
|
* - Replaces spaces and special characters with hyphens
|
|
@@ -161,7 +187,8 @@ var SlugService = class _SlugService {
|
|
|
161
187
|
if (!text) {
|
|
162
188
|
return "";
|
|
163
189
|
}
|
|
164
|
-
let slug =
|
|
190
|
+
let slug = RemoveHtmlService.create(text);
|
|
191
|
+
slug = slug.split("").map((char) => _SlugService.polishToEnglishMap[char] || char).join("");
|
|
165
192
|
slug = slug.toLowerCase();
|
|
166
193
|
slug = slug.replace(/[^a-z0-9]+/g, "-");
|
|
167
194
|
slug = slug.replace(/-+/g, "-");
|