Closed davidhq closed 3 years ago
Looks like we don't account for <title>
being present in nested nodes, for example <title>
inside of a <svg>
(which is your test case). I think the fix would be to check we're at the root-level of the document before setting the title in metadata.
I'd happily accept a change for this upstream and would like to have some tests for this too.
I'll be able to take a look at this later in the week and get a fix up.
Thank you! It would be great if you can get it fixed. If not in a week or so, I'll take a look and offer a possible fix.
:tada: This issue has been resolved in version 5.2.6 :tada:
The release is available on:
Your semantic-release bot :package::rocket:
Should be fixed now. It's not a very thorough fix so might need looking at again if other edge cases come up around this.
❯ yes | npx ts-node -e "require('./src/index.ts').unfurl('https://hash.ai').then(console.log)"
npm WARN exec The following package was not found and will be installed: ts-node
{
title: 'HASH - Complex Systems Simulation',
twitter_card: {
card: 'summary_large_image',
site: '@hashintel',
title: 'HASH - Complex Systems Simulation',
description: 'Build simulations in minutes not days. HASH is an open-source platform backed and built by the founders of Kaggle, Stack Overflow, Trello and Glitch.',
images: [ [Object] ]
},
open_graph: {
url: 'https://hash.ai/hash.ai',
title: 'HASH - Complex Systems Simulation',
description: 'Build simulations in minutes not days. HASH is an open-source platform backed and built by the founders of Kaggle, Stack Overflow, Trello and Glitch.',
images: [ [Object] ]
},
description: 'Build simulations in minutes not days. HASH is an open-source platform backed and built by the founders of Kaggle, Stack Overflow, Trello and Glitch.',
favicon: 'https://hash.ai/assets/img/brand/favicon-192.png'
}
tnx! it seems to work for this case. Didn't notice other issues for now.
Thank you very much for this great library, seems to work well, I'm currently testing it.
However:
unfurl.js
will parse the title ofhttps://hash.ai
as "Facebook".Reason:
This is the correct title and it appears first:
but later on there is more stuff with
This works correctly:
https://github.com/wzbg/read-title/blob/master/index.js
would it be possible to do it this way in your library?
Can it be done easily / soon ? If not, if you could please explain if you see this as an issue or not ... I'll think more about it and possibly fork + implement a fix myself... if there are any guidelines for me to adhere to for the fix to have a better chance of being accepted upstream, also let me know.. I'm not yet versed in typescript so the code might not be the best...
I hope it will be possible to do something in some way, so... thank you for the feedback / thoughts on this. david