Handle URLs with weird characters

This commit is contained in:
2024-11-02 00:46:02 -04:00
parent e55259357f
commit 60eb7bca64
2 changed files with 15 additions and 6 deletions

View File

@ -54,9 +54,12 @@ export default function () {
const toast = useToast();
async function deleteLink(path: string) {
const deleteResp = await fetch(`/api/short-links/${path}`, {
method: "DELETE",
});
const deleteResp = await fetch(
`/api/short-links/${encodeURIComponent(path)}`,
{
method: "DELETE",
},
);
if (!deleteResp.ok) {
let error = "Unknown error";
@ -103,7 +106,9 @@ export default function () {
<Td
onClick={() => {
navigator.clipboard.writeText(
`https://carcrushe.rs/${entry.path}`,
encodeURIComponent(
`https://carcrushe.rs/${entry.path}`,
),
);
alert("Link copied");
}}