fix: special characters in genre names (#1549)

This commit is contained in:
Phan An 2022-10-24 14:48:30 +02:00 committed by GitHub
parent 6d4b6969ef
commit 33b96fe9eb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 9 deletions

View file

@ -6,7 +6,10 @@
<div class="main-scroll-wrap">
<ul class="genres" v-if="genres">
<li v-for="genre in genres" :key="genre.name" :class="`level-${getLevel(genre)}`">
<a :href="`/#/genres/${genre.name}`" :title="`${genre.name}: ${pluralize(genre.song_count, 'song')}`">
<a
:href="`/#/genres/${encodeURIComponent(genre.name)}`"
:title="`${genre.name}: ${pluralize(genre.song_count, 'song')}`"
>
<span class="name">{{ genre.name }}</span>
<span class="count">{{ genre.song_count }}</span>
</a>

View file

@ -1,7 +1,7 @@
<template>
<section id="genreWrapper">
<ScreenHeader :layout="headerLayout" v-if="genre">
Genre: <span class="text-thin">{{ name }}</span>
Genre: <span class="text-thin">{{ decodeURIComponent(name) }}</span>
<ControlsToggle v-if="songs.length" v-model="showingControls"/>
<template v-slot:thumbnail>
@ -125,10 +125,7 @@ const refresh = async () => {
await fetch()
}
const getNameFromRoute = () => {
let param = router.$currentRoute.value.params?.name
return param ? decodeURI(param) : null
}
const getNameFromRoute = () => router.$currentRoute.value.params?.name || null
router.onRouteChanged(route => {
if (route.screen !== 'Genre') return

View file

@ -58,9 +58,9 @@ Route::prefix('api')->middleware('api')->group(static function (): void {
Route::get('songs/favorite', [FavoriteSongController::class, 'index']);
Route::delete('songs', DeleteSongsController::class);
Route::apiResource('genres', GenreController::class);
Route::get('genres/{genre}/songs', GenreSongController::class);
Route::get('genres/{genre}/songs/random', FetchRandomSongsInGenreController::class);
Route::get('genres/{genre}/songs', GenreSongController::class)->where('genre', '.*');
Route::get('genres/{genre}/songs/random', FetchRandomSongsInGenreController::class)->where('genre', '.*');
Route::apiResource('genres', GenreController::class)->where(['genre' => '.*']);
Route::apiResource('users', UserController::class);