Skip to content

Commit

Permalink
fix: escape uri
Browse files Browse the repository at this point in the history
  • Loading branch information
kahosan committed Jan 4, 2025
1 parent 82d220d commit 32bf12f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/lib/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export const handleSecondaryTitle = (title: string) => {
};

export const normalizePath = (url: string) => {
return url.replace(/[:*?"<>|']/g, '');
return encodeURIComponent(url.replace(/[:*?"<>|']/g, ''));
};

export const createAbsoluteUrl = (url: string) => {
Expand Down
6 changes: 3 additions & 3 deletions src/pages/player/[bangumi].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ import { useParams } from 'react-router-dom';
import { useBangumi } from '~/hooks/use-bangumi';
import { useWatchHistory } from '~/hooks/use-watch-history';

import { normalizePath } from '~/lib/utils';

import VideoPlayer from '~/components/video-player';

export default function Player() {
Expand All @@ -18,7 +16,9 @@ export default function Player() {
// 这里就懒得做骨架屏了
if (!data) return null;

const bangumiData = data.data.find(bangumi => normalizePath(bangumi.bangumi_name) === params.bangumi);
const bangumiData = data.data.find(bangumi => {
return bangumi.bangumi_name === params.bangumi;
});

if (!bangumiData) return <div>加载播放器出错,数据不存在</div>;

Expand Down

0 comments on commit 32bf12f

Please sign in to comment.