Skip to content

Commit 8135c14

Browse files
committed
Fix Audible results crash and deprecated meta tag
- Fix TypeError: rating.toFixed is not a function - Audible API returns rating as various types, now properly parsed - Add type checking before calling .toFixed() on ratings - Replace deprecated apple-mobile-web-app-capable meta tag
1 parent 1baf997 commit 8135c14

5 files changed

Lines changed: 24 additions & 8 deletions

File tree

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
## [2.9.14] - 2026-06-14
11+
12+
### Fixed
13+
- **Audible Results Crash** - Fixed TypeError when displaying Audible search results
14+
- Rating field from Audible API was not always a number, causing `.toFixed()` to fail
15+
- Added proper type checking before formatting rating values
16+
- **Deprecated Meta Tag** - Replaced `apple-mobile-web-app-capable` with `mobile-web-app-capable`
17+
1018
## [2.9.13] - 2026-06-14
1119

1220
### Security

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "bookshelf",
3-
"version": "2.9.13",
3+
"version": "2.9.14",
44
"description": "Personal book library management application",
55
"private": true,
66
"type": "module",

src/app.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<!-- PWA Meta Tags -->
88
<meta name="theme-color" content="#10b981" />
9-
<meta name="apple-mobile-web-app-capable" content="yes" />
9+
<meta name="mobile-web-app-capable" content="yes" />
1010
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />
1111
<meta name="apple-mobile-web-app-title" content="BookShelf" />
1212

src/lib/components/book/MetadataSearchModal.svelte

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,7 @@
379379
{#if result.publishYear}
380380
<span class="text-xs" style="color: var(--text-muted);">{result.publishYear}</span>
381381
{/if}
382-
{#if result.rating}
382+
{#if result.rating && typeof result.rating === 'number'}
383383
<span class="text-xs flex items-center gap-0.5" style="color: #fbbf24;">
384384
<Star class="w-3 h-3" style="fill: currentColor;" />
385385
{result.rating.toFixed(1)}
@@ -459,11 +459,11 @@
459459
{selectedResult.pageCount} pages
460460
</span>
461461
{/if}
462-
{#if selectedResult.rating}
462+
{#if selectedResult.rating && typeof selectedResult.rating === 'number'}
463463
<span class="px-2 py-0.5 rounded text-xs flex items-center gap-1" style="background-color: rgba(251, 191, 36, 0.1); color: #fbbf24;">
464464
<Star class="w-3 h-3" style="fill: currentColor;" />
465465
{selectedResult.rating.toFixed(1)}
466-
{#if selectedResult.ratingCount}
466+
{#if selectedResult.ratingCount && typeof selectedResult.ratingCount === 'number'}
467467
<span style="color: var(--text-muted);">({selectedResult.ratingCount.toLocaleString()})</span>
468468
{/if}
469469
</span>

src/lib/server/services/metadataProviders/audibleProvider.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -272,12 +272,20 @@ export class AudibleProvider implements MetadataProviderInterface {
272272
}
273273
}
274274

275-
// Get rating
275+
// Get rating (ensure it's a number)
276276
let rating: number | undefined;
277277
let ratingCount: number | undefined;
278278
if (product.rating?.overall_distribution) {
279-
rating = product.rating.overall_distribution.display_average_rating;
280-
ratingCount = product.rating.overall_distribution.num_ratings;
279+
const rawRating = product.rating.overall_distribution.display_average_rating;
280+
if (rawRating !== undefined && rawRating !== null) {
281+
rating = typeof rawRating === 'number' ? rawRating : parseFloat(String(rawRating));
282+
if (isNaN(rating)) rating = undefined;
283+
}
284+
const rawCount = product.rating.overall_distribution.num_ratings;
285+
if (rawCount !== undefined && rawCount !== null) {
286+
ratingCount = typeof rawCount === 'number' ? rawCount : parseInt(String(rawCount), 10);
287+
if (isNaN(ratingCount)) ratingCount = undefined;
288+
}
281289
}
282290

283291
// Get description (prefer merchandising_summary, fall back to publisher_summary)

0 commit comments

Comments
 (0)