aboutsummaryrefslogtreecommitdiff
path: root/apps/web/src/server/helpers.ts
diff options
context:
space:
mode:
authorYash <[email protected]>2024-04-11 04:52:44 +0000
committerYash <[email protected]>2024-04-11 04:52:44 +0000
commit6dcc7d18c9be5e3a5e0a3ff60668424ee0158b4e (patch)
tree179aa936536510cc707368fc7c330c4c7fbdc3f8 /apps/web/src/server/helpers.ts
parentnovel editor (diff)
parentsave user ID with url to ensure that same website can be saved by users (diff)
downloadsupermemory-new-ui.tar.xz
supermemory-new-ui.zip
Merge branch 'main' of https://github.com/Dhravya/supermemory into new-uinew-ui
Diffstat (limited to 'apps/web/src/server/helpers.ts')
-rw-r--r--apps/web/src/server/helpers.ts66
1 files changed, 33 insertions, 33 deletions
diff --git a/apps/web/src/server/helpers.ts b/apps/web/src/server/helpers.ts
index 1f6cf977..519e4b17 100644
--- a/apps/web/src/server/helpers.ts
+++ b/apps/web/src/server/helpers.ts
@@ -1,34 +1,34 @@
export async function getMetaData(url: string) {
- const response = await fetch(url);
- const html = await response.text();
-
- // Extract the base URL
- const baseUrl = new URL(url).origin;
-
- // Extract title
- const titleMatch = html.match(/<title>(.*?)<\/title>/);
- const title = titleMatch ? titleMatch[1] : 'Title not found';
-
- // Extract meta description
- const descriptionMatch = html.match(
- /<meta name="description" content="(.*?)"\s*\/?>/,
- );
- const description = descriptionMatch
- ? descriptionMatch[1]
- : 'Description not found';
-
- // Extract Open Graph image
- const imageMatch = html.match(
- /<meta property="og:image" content="(.*?)"\s*\/?>/,
- );
- const image = imageMatch ? imageMatch[1] : 'Image not found';
-
- // Prepare the metadata object
- const metadata = {
- title,
- description,
- image,
- baseUrl,
- };
- return metadata;
- } \ No newline at end of file
+ const response = await fetch(url);
+ const html = await response.text();
+
+ // Extract the base URL
+ const baseUrl = new URL(url).origin;
+
+ // Extract title
+ const titleMatch = html.match(/<title>(.*?)<\/title>/);
+ const title = titleMatch ? titleMatch[1] : "Title not found";
+
+ // Extract meta description
+ const descriptionMatch = html.match(
+ /<meta name="description" content="(.*?)"\s*\/?>/,
+ );
+ const description = descriptionMatch
+ ? descriptionMatch[1]
+ : "Description not found";
+
+ // Extract Open Graph image
+ const imageMatch = html.match(
+ /<meta property="og:image" content="(.*?)"\s*\/?>/,
+ );
+ const image = imageMatch ? imageMatch[1] : "Image not found";
+
+ // Prepare the metadata object
+ const metadata = {
+ title,
+ description,
+ image,
+ baseUrl,
+ };
+ return metadata;
+}