Skip to content

Commit

Permalink
fix: Do not rely on .article-div (#262)
Browse files Browse the repository at this point in the history
SW-KA have pushed an update where some wrapper elements are no
longer present on the page. This breaks 'simplesite' plan parsing. By
simplifying the DOM selector, this patch restores it to a working
condition while keeping backwards-compatibility.
  • Loading branch information
meyfa authored Jul 1, 2024
1 parent 80028dd commit 8ec5533
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 14 deletions.
2 changes: 1 addition & 1 deletion src/simplesite/simplesite-parse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ function parseMeal ($: CheerioAPI, $row: Cheerio<Element>): CanteenMeal | undefi
*/
export function parse (html: string, canteenId: string, referenceDate: Date): CanteenPlan[] {
const $ = load(html)
const $titles = $('#platocontent .article-div > h1')
const $titles = $('#platocontent h1')

// The canteen name is stored in the first <h1>.
const canteenName = $titles.first().text()
Expand Down
22 changes: 9 additions & 13 deletions test/simplesite/simplesite-parse.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,15 @@ function wrapContent (canteenName: string, content: string): string {
<tr>
<td>
<div id="platocontent" class="platocontent">
<article>
<div class="article-div">
<h1 class="mensa_fullname">${canteenName}</h1>
<h1>${canteenName}</h1>
Preise für Studenten
<p><style></style></p>
${content}
<b>Legende</b><br>
(1) mit Farbstoff<br>
<b>Freiwillige Angaben</b><br>
[R] enthält Rindfleisch
</div>
</article>
<h1 class="mensa_fullname">${canteenName}</h1>
<h1>${canteenName}</h1>
Preise für Studierende
<p><style></style></p>
${content}
<b>Legende</b><br>
(1) mit Farbstoff<br>
<b>Freiwillige Angaben</b><br>
[R] enthält Rindfleisch
</div>
</td>
<td>
Expand Down

0 comments on commit 8ec5533

Please sign in to comment.