PluginProbe
Yatra – Travel Booking & Tour Operator Software / 3.0.16
Yatra – Travel Booking & Tour Operator Software v3.0.16
3.0.16 3.0.15 3.0.14 3.0.14.1 3.0.14.2 3.0.12 3.0.13 3.0.11 3.0.10 3.0.9 3.0.8 3.0.7 3.0.6 3.0.5 3.0.5.1 3.0.4 3.0.3 3.0.2.9 3.0.2.7 3.0.2.8 3.0.2.6 trunk 1.0.0 2.0.0 2.0.1 All 84 releases
yatra / resources / js / blocks / utils / migrateTaxonomyIds.ts

migrateTaxonomyIds.ts in Yatra – Travel Booking & Tour Operator Software 3.0.16, at resources/js/blocks/utils/migrateTaxonomyIds.ts

31 lines 725 B
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 /**
2 * Migrate legacy comma-separated numeric ID strings into block attribute ID arrays.
3 * Returns [] if the string contains any non‑numeric token (e.g. old slug-based values).
4 */
5 export function migrateNumericCsvPairToIds(
6 legacyA?: string,
7 legacyB?: string,
8 ): number[] {
9 const raw = [legacyA ?? "", legacyB ?? ""].find(
10 (s) => String(s).trim() !== "",
11 );
12 if (raw === undefined) {
13 return [];
14 }
15 const parts = String(raw)
16 .split(",")
17 .map((s) => s.trim())
18 .filter(Boolean);
19 const ids: number[] = [];
20 for (const p of parts) {
21 if (!/^\d+$/.test(p)) {
22 return [];
23 }
24 const n = parseInt(p, 10);
25 if (n > 0) {
26 ids.push(n);
27 }
28 }
29 return [...new Set(ids)];
30 }
31