Skip to content

Commit

Permalink
fix(server): trim title suggestions, fixes #162
Browse files Browse the repository at this point in the history
  • Loading branch information
neopostmodern committed Aug 19, 2022
1 parent cf3e6e9 commit a8a6402
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 4 deletions.
2 changes: 1 addition & 1 deletion server/lib/methods.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export async function fetchTitleSuggestions(url) {
const titleBag = [
dom.window.document.querySelector('title').innerHTML,
...metaTitles,
].map((rawTitle) => decode(rawTitle))
].map((rawTitle) => decode(rawTitle).trim())

return titleBag.filter(
(title, index) => titleBag.indexOf(title) === index,
Expand Down
4 changes: 1 addition & 3 deletions server/lib/resolvers.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,9 +151,7 @@ const rootResolvers = {
throw new Error(`No link with ID ${linkId}`)
}
try {
let x = await fetchTitleSuggestions(link.url)
console.log(link.url, x)
return x
return fetchTitleSuggestions(link.url)
} catch (error) {
console.warn(`Failed to fetch title suggestions for ${linkId}`, error)
return []
Expand Down

0 comments on commit a8a6402

Please sign in to comment.