From 1752fe5922900426f9d1a7716b1248bc7c4e64da Mon Sep 17 00:00:00 2001 From: Vandivier Date: Thu, 23 May 2024 21:43:18 -0400 Subject: [PATCH] fix: parse url --- .../components/UserChecklistQueryHandler.tsx | 3 ++- src/core/utils/parsing.ts | 20 +++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 src/core/utils/parsing.ts diff --git a/src/app/user-checklists/components/UserChecklistQueryHandler.tsx b/src/app/user-checklists/components/UserChecklistQueryHandler.tsx index 4fd98cfb..317dc97a 100644 --- a/src/app/user-checklists/components/UserChecklistQueryHandler.tsx +++ b/src/app/user-checklists/components/UserChecklistQueryHandler.tsx @@ -5,6 +5,7 @@ import React from "react" import updateUserChecklistItem from "src/app/user-checklist-items/mutations/updateUserChecklistItem" import getLatestUserChecklistByName from "src/app/user-checklists/queries/getLatestUserChecklistByName" import { UserChecklistItemWithChecklistItem } from "src/app/user-checklists/schemas" +import { parseUrl } from "src/core/utils/parsing" const MAGIC_LINK_SUBSTR = "###LINK###" @@ -64,7 +65,7 @@ const UserChecklistItemList = ({ {part} { + try { + const urlObject = new URL(url) + + return { + pathname: `${urlObject.origin}${urlObject.pathname}`, + search: urlObject.search, + } + } catch (e) { + return { + pathname: url, + search: "", + } + } +}