@escapenavigator/utils 1.10.132 → 1.10.134

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.
@@ -0,0 +1,71 @@
1
+ "use strict";
2
+ /**
3
+ * Узкая проверка опций `sanitizeQuillHtml` (особенно `stripLinks`,
4
+ * добавленной для полей с `noLinks={true}` в location-форме).
5
+ *
6
+ * Полная регрессия `normalizeQuillWhitespace` / `stripQuillColors` —
7
+ * предмет отдельных рег-тестов; здесь ловим именно регрессию ссылок.
8
+ */
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ const sanitize_quill_html_1 = require("./sanitize-quill-html");
11
+ describe('stripQuillLinks', () => {
12
+ it('убирает `<a>`-обёртку, оставляет текст', () => {
13
+ const html = 'click <a href="https://example.com">here</a> to donate';
14
+ expect((0, sanitize_quill_html_1.stripQuillLinks)(html)).toBe('click here to donate');
15
+ });
16
+ it('поддерживает вложенные форматы внутри ссылки', () => {
17
+ const html = '<strong><a href="https://x.com" rel="noopener" target="_blank">here</a></strong>';
18
+ expect((0, sanitize_quill_html_1.stripQuillLinks)(html)).toBe('<strong>here</strong>');
19
+ });
20
+ it('обрабатывает несколько ссылок', () => {
21
+ const html = '<a href="a">one</a> and <a href="b">two</a>';
22
+ expect((0, sanitize_quill_html_1.stripQuillLinks)(html)).toBe('one and two');
23
+ });
24
+ it('идемпотентна', () => {
25
+ const html = 'click <a href="x">here</a>';
26
+ expect((0, sanitize_quill_html_1.stripQuillLinks)((0, sanitize_quill_html_1.stripQuillLinks)(html))).toBe((0, sanitize_quill_html_1.stripQuillLinks)(html));
27
+ });
28
+ it('игнорирует пустой ввод', () => {
29
+ expect((0, sanitize_quill_html_1.stripQuillLinks)('')).toBe('');
30
+ });
31
+ });
32
+ describe('sanitizeQuillHtml — combo `stripLinks` + nbsp + colors', () => {
33
+ it('по умолчанию ссылки сохраняет, &nbsp; нормализует', () => {
34
+ const html = '<p><a href="x">link</a>&nbsp;text</p>';
35
+ expect((0, sanitize_quill_html_1.sanitizeQuillHtml)(html)).toBe('<p><a href="x">link</a> text</p>');
36
+ });
37
+ it('`stripLinks: true` убирает ссылку, оставляет текст и нормализует пробелы', () => {
38
+ const html = '<p>click <a href="https://x">here</a>&nbsp;to&nbsp;donate</p>';
39
+ expect((0, sanitize_quill_html_1.sanitizeQuillHtml)(html, { stripLinks: true })).toBe('<p>click here to donate</p>');
40
+ });
41
+ it('`stripColors: true` + `stripLinks: true` чистит и цвет, и ссылку', () => {
42
+ const html = '<p style="color: red;"><a href="x" style="color: red;">link</a> text</p>';
43
+ const result = (0, sanitize_quill_html_1.sanitizeQuillHtml)(html, { stripColors: true, stripLinks: true });
44
+ expect(result).not.toContain('<a');
45
+ expect(result).not.toContain('color');
46
+ expect(result).toContain('link');
47
+ });
48
+ it('кеш разделяет результаты для разных опций', () => {
49
+ const html = '<a href="x">y</a>';
50
+ const withLinks = (0, sanitize_quill_html_1.sanitizeQuillHtml)(html);
51
+ const stripped = (0, sanitize_quill_html_1.sanitizeQuillHtml)(html, { stripLinks: true });
52
+ expect(withLinks).toContain('<a');
53
+ expect(stripped).not.toContain('<a');
54
+ // Повторный вызов с теми же опциями возвращает тот же результат
55
+ expect((0, sanitize_quill_html_1.sanitizeQuillHtml)(html, { stripLinks: true })).toBe(stripped);
56
+ });
57
+ it('пустой/null/undefined ввод → пустая строка', () => {
58
+ expect((0, sanitize_quill_html_1.sanitizeQuillHtml)('', { stripLinks: true })).toBe('');
59
+ expect((0, sanitize_quill_html_1.sanitizeQuillHtml)(null, { stripLinks: true })).toBe('');
60
+ expect((0, sanitize_quill_html_1.sanitizeQuillHtml)(undefined, { stripLinks: true })).toBe('');
61
+ });
62
+ });
63
+ describe('stripQuillColors smoke', () => {
64
+ it('убирает inline color/background style', () => {
65
+ const html = '<p style="color: red; background: yellow;">text</p>';
66
+ const result = (0, sanitize_quill_html_1.stripQuillColors)(html);
67
+ expect(result).not.toContain('color');
68
+ expect(result).not.toContain('background');
69
+ expect(result).toContain('text');
70
+ });
71
+ });
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.serializeSlot = exports.serializeSlotOrderData = void 0;
4
4
  const defailt_rule_1 = require("@escapenavigator/types/dist/slot-rule/defailt-rule");
5
5
  const buildRuleSummary = (rule) => {
6
- const { prepayment, prepaymentType, title, minHoursForBooking, minHoursForFreeCanceling, cancelationRule, minHoursForFullFine, cancelationAmount, } = rule || defailt_rule_1.defaultRule;
6
+ const { prepayment, prepaymentType, title, minHoursForBooking, minMinutesForBooking, minHoursForFreeCanceling, cancelationRule, minHoursForFullFine, cancelationAmount, } = rule || defailt_rule_1.defaultRule;
7
7
  return {
8
8
  prepayment,
9
9
  minHoursForFullFine,
@@ -11,6 +11,7 @@ const buildRuleSummary = (rule) => {
11
11
  prepaymentType,
12
12
  title,
13
13
  minHoursForBooking,
14
+ minMinutesForBooking: minMinutesForBooking ?? (minHoursForBooking ?? 0) * 60,
14
15
  minHoursForFreeCanceling,
15
16
  cancelationRule,
16
17
  };
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Убираем HTML-теги из строки и схлопываем пробелы.
3
+ *
4
+ * Используется, когда поле раньше редактировалось через Quill (и в БД мог
5
+ * попасть HTML), а теперь рендерится в обычном `<Textarea>`/inline-тексте.
6
+ * Если не вычистить, пользователь видит `<p>текст</p>` буквально (см. `teaser`
7
+ * в форме редактирования квеста: на момент миграции с Quill на Textarea в
8
+ * локалях остались записи с открывающими/закрывающими тегами).
9
+ *
10
+ * Функция чистая и идемпотентная: повторный вызов на уже очищенной строке
11
+ * возвращает её же.
12
+ */
13
+ export declare function stripHtmlTags(text: string | null | undefined): string;
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.stripHtmlTags = stripHtmlTags;
4
+ /**
5
+ * Убираем HTML-теги из строки и схлопываем пробелы.
6
+ *
7
+ * Используется, когда поле раньше редактировалось через Quill (и в БД мог
8
+ * попасть HTML), а теперь рендерится в обычном `<Textarea>`/inline-тексте.
9
+ * Если не вычистить, пользователь видит `<p>текст</p>` буквально (см. `teaser`
10
+ * в форме редактирования квеста: на момент миграции с Quill на Textarea в
11
+ * локалях остались записи с открывающими/закрывающими тегами).
12
+ *
13
+ * Функция чистая и идемпотентная: повторный вызов на уже очищенной строке
14
+ * возвращает её же.
15
+ */
16
+ function stripHtmlTags(text) {
17
+ if (!text)
18
+ return '';
19
+ return text
20
+ .replace(/<[^>]+>/g, ' ')
21
+ .replace(/&nbsp;|&#160;|&#xa0;|\u00A0/gi, ' ')
22
+ .replace(/\s+/g, ' ')
23
+ .trim();
24
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@escapenavigator/utils",
3
- "version": "1.10.132",
3
+ "version": "1.10.134",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -14,11 +14,12 @@
14
14
  "test": "jest"
15
15
  },
16
16
  "dependencies": {
17
- "@escapenavigator/types": "^1.10.128",
17
+ "@escapenavigator/types": "^1.10.130",
18
18
  "axios": "^0.21.4",
19
19
  "class-transformer": "^0.5.1",
20
20
  "class-validator": "^0.13.2",
21
21
  "i18next": "^21.6.4",
22
+ "node-html-parser": "^7.1.0",
22
23
  "quill-delta": "^5.1.0"
23
24
  },
24
25
  "devDependencies": {
@@ -27,5 +28,5 @@
27
28
  "ts-jest": "^29.1.1",
28
29
  "typescript": "^5.6"
29
30
  },
30
- "gitHead": "f314b83d632fc068719426b472f60ab03213d533"
31
+ "gitHead": "1b34f498be3d6fb27dccdd2a3663cef5169bbc91"
31
32
  }