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"> <div class="main-scroll-wrap">
<ul class="genres" v-if="genres"> <ul class="genres" v-if="genres">
<li v-for="genre in genres" :key="genre.name" :class="`level-${getLevel(genre)}`"> <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="name">{{ genre.name }}</span>
<span class="count">{{ genre.song_count }}</span> <span class="count">{{ genre.song_count }}</span>
</a> </a>

View file

@ -1,7 +1,7 @@
<template> <template>
<section id="genreWrapper"> <section id="genreWrapper">
<ScreenHeader :layout="headerLayout" v-if="genre"> <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"/> <ControlsToggle v-if="songs.length" v-model="showingControls"/>
<template v-slot:thumbnail> <template v-slot:thumbnail>
@ -125,10 +125,7 @@ const refresh = async () => {
await fetch() await fetch()
} }
const getNameFromRoute = () => { const getNameFromRoute = () => router.$currentRoute.value.params?.name || null
let param = router.$currentRoute.value.params?.name
return param ? decodeURI(param) : null
}
router.onRouteChanged(route => { router.onRouteChanged(route => {
if (route.screen !== 'Genre') return 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::get('songs/favorite', [FavoriteSongController::class, 'index']);
Route::delete('songs', DeleteSongsController::class); Route::delete('songs', DeleteSongsController::class);
Route::apiResource('genres', GenreController::class); Route::get('genres/{genre}/songs', GenreSongController::class)->where('genre', '.*');
Route::get('genres/{genre}/songs', GenreSongController::class); Route::get('genres/{genre}/songs/random', FetchRandomSongsInGenreController::class)->where('genre', '.*');
Route::get('genres/{genre}/songs/random', FetchRandomSongsInGenreController::class); Route::apiResource('genres', GenreController::class)->where(['genre' => '.*']);
Route::apiResource('users', UserController::class); Route::apiResource('users', UserController::class);