From 619ccc21156e25870c6083857c7ebe346ae765ff Mon Sep 17 00:00:00 2001 From: ritz078 Date: Thu, 4 Jun 2020 04:40:18 +0530 Subject: [PATCH] fix(default): check if the parameter exists in url before calling decodeURI --- renderer/components/Container/Container.tsx | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/renderer/components/Container/Container.tsx b/renderer/components/Container/Container.tsx index 4d18da6e..0cb886cf 100644 --- a/renderer/components/Container/Container.tsx +++ b/renderer/components/Container/Container.tsx @@ -17,8 +17,10 @@ import MagnetUri from "magnet-uri"; import ParseTorrent from "parse-torrent"; const { searchParams } = new URL(window.location.href); -const path = decodeURI(searchParams.get("path")); -const magnetUri = decodeURI(searchParams.get("magnet")); + +const path = searchParams.get("path") && decodeURI(searchParams.get("path")); +const magnetUri = + searchParams.get("magnet") && decodeURI(searchParams.get("magnet")); export default function () { const [selectedTorrent, setSelectedTorrent] = useState( @@ -100,6 +102,7 @@ export default function () { useEffect(() => { function loadMagnetUri(_magnetUri: string) { + debugger; if (!_magnetUri) return; try { const { name, infoHash }: MagnetUri.Instance = ParseTorrent(_magnetUri);