Skip to content

Commit

Permalink
Merge pull request #126 from andypiper/bulk-import-fix
Browse files Browse the repository at this point in the history
Another quick fix for bulk simple import, remove newlines more cleanly.
  • Loading branch information
ckolderup committed Sep 22, 2023
2 parents 674706d + 1b64fbf commit 199414c
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/routes/bookmark.js
Original file line number Diff line number Diff line change
Expand Up @@ -159,10 +159,12 @@ router.post('/multiadd', isAuthenticated, async (req, res) => {
}

if (url.length < 3) return;
// remove line break from URL value
const link = url.replace(/(\r\n|\n|\r)/gm, '');

let meta = {};
try {
meta = await ogScraper({ url: url.replace(/(\r\n|\n|\r)/gm, '') }); // remove line break from URL value
meta = await ogScraper({ url: link });
if (meta?.result?.ogDescription !== undefined) {
meta.result.ogDescription = `"${meta.result.ogDescription}"`;
}
Expand All @@ -171,9 +173,9 @@ router.post('/multiadd', isAuthenticated, async (req, res) => {
}

await bookmarksDb.createBookmark({
url,
url: link,
title: meta.result.ogTitle,
description: meta.result.ogDescription,
description: meta.result.ogDescription || ' ', // add *something*, even if ogDesc is empty (keeps Atom feed validation happy)
});
});

Expand Down

0 comments on commit 199414c

Please sign in to comment.