zdu-student-api 1.1.11 → 1.1.13

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.
@@ -71,6 +71,13 @@ function parseSchedule(html) {
71
71
  if (thirdTrStart === -1 || thirdTrEnd === -1)
72
72
  return [];
73
73
  let thirdRow = theadContent.slice(thirdTrStart, thirdTrEnd);
74
+ // Збираємо всі data-ind з thead в порядку появи (вони у другому рядку)
75
+ const allInds = [];
76
+ const indRegex = /data-ind="([^"]+)"/g;
77
+ let indMatch;
78
+ while ((indMatch = indRegex.exec(theadContent)) !== null) {
79
+ allInds.push(indMatch[1]);
80
+ }
74
81
  const result = [];
75
82
  const thStartRegex = /<th\b/g;
76
83
  const positions = [];
@@ -85,6 +92,7 @@ function parseSchedule(html) {
85
92
  thirdPositions.push(match.index);
86
93
  }
87
94
  thirdPositions.push(thirdRow.length);
95
+ let indIdx = 0;
88
96
  for (let i = 0; i < positions.length - 1; i++) {
89
97
  const start = positions[i];
90
98
  const end = positions[i + 1];
@@ -118,11 +126,18 @@ function parseSchedule(html) {
118
126
  if (!dataHthMatch)
119
127
  continue;
120
128
  const dataHth = dataHthMatch[1];
129
+ let index;
121
130
  const aMatch = thContent.match(/data-ind="([^"]+)"/);
122
- if (!aMatch)
123
- continue;
124
- const index = aMatch[1];
125
- const dateMatch = thContent.match(/>(\d{2}\.\d{2}\.\d{4})</);
131
+ if (aMatch) {
132
+ index = aMatch[1];
133
+ }
134
+ else {
135
+ if (indIdx >= allInds.length)
136
+ continue;
137
+ index = allInds[indIdx];
138
+ }
139
+ indIdx++;
140
+ const dateMatch = thContent.match(/(\d{2}\.\d{2}\.\d{4})/);
126
141
  const date = dateMatch ? dateMatch[1] : '';
127
142
  const timeMatch = thContent.match(/<br[^>]*>\s*(\d{2}:\d{2}-\d{2}:\d{2})/);
128
143
  const time = timeMatch ? timeMatch[1].trim() : '';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zdu-student-api",
3
- "version": "1.1.11",
3
+ "version": "1.1.13",
4
4
  "description": "API client for ZDU student services",
5
5
  "author": "Nicita3 <ni596157@gmail.com> (https://github.com/Nicita-3)",
6
6
  "main": "dist/index.js",
@@ -13,7 +13,7 @@
13
13
  "build": "tsc",
14
14
  "docs": "typedoc --out docs src",
15
15
  "test": "node --loader ts-node/esm src/examples.ts",
16
- "publish:all": "npm run build && npm run docs && npm publish"
16
+ "publish:all": "npm run build && npm publish"
17
17
  },
18
18
  "license": "MIT",
19
19
  "repository": {