Skip to content

Papermark is the open-source DocSend alternative and secure data rooms with built-in analytics and custom domains.

fix: remove logs

Marc Seitzc0f0eecbdf96
diff --git a/app/(ee)/api/workflow-entry/domains/[...domainSlug]/route.ts b/app/(ee)/api/workflow-entry/domains/[...domainSlug]/route.ts
index 3d8d9e4c..444e26b1 100644
--- a/app/(ee)/api/workflow-entry/domains/[...domainSlug]/route.ts
+++ b/app/(ee)/api/workflow-entry/domains/[...domainSlug]/route.ts
@@ -299,12 +299,22 @@ async function handleAccess(req: NextRequest, link: any) {
executionResult.targetDataroomId,
);
- const targetPath = executionResult.targetUrl
- ? new URL(executionResult.targetUrl).pathname
- : "/";
- const cookieFlagId = executionResult.targetUrl
- ? new URL(executionResult.targetUrl).pathname.split("/").pop()
- : executionResult.targetLinkId;
+ // Parse target URL safely with fallback
+ let targetPath = "/";
+ let cookieFlagId = executionResult.targetLinkId;
+
+ if (executionResult.targetUrl) {
+ try {
+ const parsedUrl = new URL(executionResult.targetUrl);
+ targetPath = parsedUrl.pathname;
+ const pathSegment = parsedUrl.pathname.split("/").pop();
+ if (pathSegment) {
+ cookieFlagId = pathSegment;
+ }
+ } catch (error) {
+ console.error("Failed to parse target URL, using fallback values");
+ }
+ }
// Set link session cookie (httpOnly)
cookies().set(`pm_ls_${executionResult.targetLinkId}`, sessionToken, {
@@ -363,12 +373,6 @@ async function handleAccess(req: NextRequest, link: any) {
});
}
- console.log("--------------------------------");
- console.log("sessionToken", sessionToken);
- console.log("--------------------------------");
- console.log("executionResult", executionResult);
- console.log("--------------------------------");
-
return NextResponse.json({
success: true,
targetUrl: executionResult.targetUrl,
diff --git a/app/(ee)/api/workflow-entry/link/[entryLinkId]/access/route.ts b/app/(ee)/api/workflow-entry/link/[entryLinkId]/access/route.ts
index 05cbcef9..f3156310 100644
--- a/app/(ee)/api/workflow-entry/link/[entryLinkId]/access/route.ts
+++ b/app/(ee)/api/workflow-entry/link/[entryLinkId]/access/route.ts
@@ -195,8 +195,22 @@ export async function POST(
executionResult.targetDataroomId,
);
- const targetPath = `/view/${executionResult.targetLinkId}`;
- const cookieFlagId = executionResult.targetLinkId;
+ // Parse target URL safely with fallback
+ let targetPath = `/view/${executionResult.targetLinkId}`;
+ let cookieFlagId = executionResult.targetLinkId;
+
+ if (executionResult.targetUrl) {
+ try {
+ const parsedUrl = new URL(executionResult.targetUrl);
+ targetPath = parsedUrl.pathname;
+ const pathSegment = parsedUrl.pathname.split("/").pop();
+ if (pathSegment) {
+ cookieFlagId = pathSegment;
+ }
+ } catch (error) {
+ console.error("Failed to parse target URL, using fallback values");
+ }
+ }
// Set link session cookie (httpOnly)
cookies().set(`pm_ls_${executionResult.targetLinkId}`, sessionToken, {
@@ -255,12 +269,6 @@ export async function POST(
});
}
- console.log("--------------------------------");
- console.log("sessionToken", sessionToken);
- console.log("--------------------------------");
- console.log("executionResult", executionResult);
- console.log("--------------------------------");
-
return NextResponse.json({
success: true,
targetUrl: executionResult.targetUrl,