chuvsu-js 2.6.0 → 2.6.1

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/dist/tt/parse.js CHANGED
@@ -130,9 +130,16 @@ function parseTransferDiv(div) {
130
130
  return null;
131
131
  const roomMatch = divHtml.match(/([А-Яа-яA-Za-z]-\d+)/);
132
132
  const typeMatch = divText.match(/\((лк|пр|лб|зач|экз|зчО|кр|конс)\)/);
133
- // Teacher: last text line before closing </div>
133
+ // Teacher: last text line that isn't a subgroup marker
134
134
  const parts = divHtml.split(/<br\s*\/?>/);
135
- const lastPart = parts[parts.length - 1]?.replace(/<[^>]*>/g, "").trim();
135
+ let teacherPart = "";
136
+ for (let i = parts.length - 1; i >= 0; i--) {
137
+ const clean = parts[i].replace(/<[^>]*>/g, "").trim();
138
+ if (clean && !/подгруппа/.test(clean)) {
139
+ teacherPart = clean;
140
+ break;
141
+ }
142
+ }
136
143
  const transfer = { targetDate, fromDate, fromSlot, subject };
137
144
  const subgroupMatch = divText.match(/(\d+)\s*подгруппа/);
138
145
  return {
@@ -142,7 +149,7 @@ function parseTransferDiv(div) {
142
149
  subject,
143
150
  type: typeMatch?.[1] ?? "",
144
151
  weeks: { from: 0, to: 0 },
145
- teacher: parseTeacher(lastPart ?? ""),
152
+ teacher: parseTeacher(teacherPart),
146
153
  subgroup: subgroupMatch ? parseInt(subgroupMatch[1]) : undefined,
147
154
  transfer,
148
155
  },
package/dist/tt/utils.js CHANGED
@@ -95,6 +95,10 @@ function isSameDay(a, b) {
95
95
  }
96
96
  function filterEntries(entries, opts) {
97
97
  return entries.filter((e) => {
98
+ // Subgroup filter applies to all entry types
99
+ if (opts?.subgroup && e.subgroup && e.subgroup !== opts.subgroup) {
100
+ return false;
101
+ }
98
102
  // Transfer entries: only include when the query date matches the target date
99
103
  if (e.transfer) {
100
104
  if (!opts?.date)
@@ -107,9 +111,6 @@ function filterEntries(entries, opts) {
107
111
  return false;
108
112
  return isSameDay(e.substituteFor.date, opts.date);
109
113
  }
110
- if (opts?.subgroup && e.subgroup && e.subgroup !== opts.subgroup) {
111
- return false;
112
- }
113
114
  if (opts?.week != null) {
114
115
  if (e.weeks.from > 0 &&
115
116
  (opts.week < e.weeks.from || opts.week > e.weeks.to)) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "chuvsu-js",
3
- "version": "2.6.0",
3
+ "version": "2.6.1",
4
4
  "description": "Node.js library for ChuvSU student portal (lk.chuvsu.ru) and schedule (tt.chuvsu.ru)",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",