Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions src/connections/Linkedin/connection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { GenerationProgress } from "../types";
import { getSpacePortal, registerAuthCookies, reqSpaceCreation } from "../../driver";
import wikiIcon from "data-base64:../../../assets/wiki.png";

import { v4 as uuidv4 } from 'uuid';
import { getUuidV4 } from "../../driver";



Expand Down Expand Up @@ -65,7 +65,7 @@ const createSpace = async (
const company = row[companyIdx];
const url = linkIdx !== -1 ? row[linkIdx] : "";
result.push({
uuid: uuidv4(),
uuid: getUuidV4(),
title: `Applied Job: ${title}`,
text: `Applied to ${title} at ${company}`,
link: url,
Expand Down Expand Up @@ -122,7 +122,7 @@ const createSpace = async (
const name = document.querySelector("h1.text-heading-xlarge")?.textContent?.trim() || "Unknown Name";
const headline = document.querySelector(".text-body-medium.break-words")?.textContent?.trim() || "";
extractedData.push({
uuid: uuidv4(),
uuid: getUuidV4(),
title: name,
text: sanitize(headline),
link: window.location.href,
Expand All @@ -139,7 +139,7 @@ const createSpace = async (
const about = aboutSection?.innerText?.trim();
if (about) {
extractedData.push({
uuid: uuidv4(),
uuid: getUuidV4(),
title: "About",
text: sanitize(about),
link: window.location.href,
Expand All @@ -161,7 +161,7 @@ const createSpace = async (
const description = entry.innerText?.trim();
if (jobTitle && description) {
extractedData.push({
uuid: uuidv4(),
uuid: getUuidV4(),
title: `Experience: ${jobTitle}`,
text: sanitize(description),
link: window.location.href,
Expand All @@ -184,7 +184,7 @@ const createSpace = async (
const eduDetails = entry.innerText?.trim();
if (school && eduDetails) {
extractedData.push({
uuid: uuidv4(),
uuid: getUuidV4(),
title: `Education: ${school}`,
text: sanitize(eduDetails),
link: window.location.href,
Expand All @@ -206,7 +206,7 @@ const createSpace = async (
if (!seen.has(connectionUrl)) {
seen.add(connectionUrl);
extractedData.push({
uuid: uuidv4(),
uuid: getUuidV4(),
title: `Connection: ${connectionName}`,
text: `Connected with ${connectionName}`,
link: connectionUrl,
Expand All @@ -232,7 +232,7 @@ if (activitySection) {
const postContent = card.textContent?.trim().replace(/\s+/g, " ") || "LinkedIn Activity";

extractedData.push({
uuid: uuidv4(),
uuid: getUuidV4(),
title: `Activity: ${postContent.slice(0, 40)}...`,
text: postContent,
link: postUrl,
Expand Down Expand Up @@ -269,7 +269,7 @@ const getMessagesFromIframe = async (): Promise<any[]> => {
: "https://www.linkedin.com/messaging/";

return {
uuid: uuidv4(),
uuid: getUuidV4(),
title: `Message with ${name}`,
text: `${timestamp} - ${snippet}`,
link: threadUrl,
Expand Down Expand Up @@ -312,7 +312,7 @@ const getFollowedCompanies = async (): Promise<any[]> => {
const link = (card.querySelector("a") as HTMLAnchorElement)?.href || "";

return {
uuid: uuidv4(),
uuid: getUuidV4(),
title: `Following: ${name}`,
text: subtitle,
link,
Expand Down
2 changes: 1 addition & 1 deletion src/content.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -573,7 +573,7 @@ const ConnectionDialog = ({ activeConnections, close }: { activeConnections: Man
Space was created successfully and injected{" "}
<span className="text-blue-600">
<a
href={`https://mantisdev.csail.mit.edu/space/${spaceId}/`}
href={`${process.env.PLASMO_PUBLIC_FRONTEND}/space/${spaceId}/`}
Copy link
Contributor

Choose a reason for hiding this comment

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

high

While using an environment variable is a great improvement to remove the hardcoded URL, there's a potential issue if PLASMO_PUBLIC_FRONTEND is not set. In that case, process.env.PLASMO_PUBLIC_FRONTEND will be undefined, and the resulting URL will be something like undefined/space/..., which is a broken link.

To make this more robust, I suggest adding a check for the environment variable. If it's not present, we can fall back to a safe value like '#' to prevent a broken link. This provides a better user experience than a link that leads to an error page.

Suggested change
href={`${process.env.PLASMO_PUBLIC_FRONTEND}/space/${spaceId}/`}
href={process.env.PLASMO_PUBLIC_FRONTEND ? `${process.env.PLASMO_PUBLIC_FRONTEND}/space/${spaceId}/` : '#'}

target="_blank"
rel="noopener noreferrer"
>
Expand Down