Skip to content

Commit

Permalink
fix(default): check if the parameter exists in url before calling dec…
Browse files Browse the repository at this point in the history
…odeURI
  • Loading branch information
ritz078 committed Jun 3, 2020
1 parent 18b6065 commit 619ccc2
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions renderer/components/Container/Container.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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<DownloadingTorrent>(
Expand Down Expand Up @@ -100,6 +102,7 @@ export default function () {

useEffect(() => {
function loadMagnetUri(_magnetUri: string) {
debugger;
if (!_magnetUri) return;
try {
const { name, infoHash }: MagnetUri.Instance = ParseTorrent(_magnetUri);
Expand Down

1 comment on commit 619ccc2

@vercel
Copy link

@vercel vercel bot commented on 619ccc2 Jun 3, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.