Spaces:
Sleeping
Sleeping
Fix share link when already created (#110)
Browse files
src/routes/conversation/[id]/share/+server.ts
CHANGED
@@ -24,7 +24,7 @@ export async function POST({ params, url, locals }) {
|
|
24 |
if (existingShare) {
|
25 |
return new Response(
|
26 |
JSON.stringify({
|
27 |
-
url: (
|
28 |
}),
|
29 |
{ headers: { "Content-Type": "application/json" } }
|
30 |
);
|
@@ -43,8 +43,12 @@ export async function POST({ params, url, locals }) {
|
|
43 |
|
44 |
return new Response(
|
45 |
JSON.stringify({
|
46 |
-
url:
|
47 |
}),
|
48 |
{ headers: { "Content-Type": "application/json" } }
|
49 |
);
|
50 |
}
|
|
|
|
|
|
|
|
|
|
24 |
if (existingShare) {
|
25 |
return new Response(
|
26 |
JSON.stringify({
|
27 |
+
url: getShareUrl(url, existingShare._id),
|
28 |
}),
|
29 |
{ headers: { "Content-Type": "application/json" } }
|
30 |
);
|
|
|
43 |
|
44 |
return new Response(
|
45 |
JSON.stringify({
|
46 |
+
url: getShareUrl(url, shared._id),
|
47 |
}),
|
48 |
{ headers: { "Content-Type": "application/json" } }
|
49 |
);
|
50 |
}
|
51 |
+
|
52 |
+
function getShareUrl(url: URL, shareId: string): string {
|
53 |
+
return `${PUBLIC_ORIGIN || url.origin}${base}/r/${shareId}`;
|
54 |
+
}
|