aboutsummaryrefslogtreecommitdiff
path: root/apps/web/src/server/helpers.ts
diff options
context:
space:
mode:
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;
+}