ritz078 / embed-js

🌻 A lightweight plugin to embed emojis, media, maps, tweets, code and more. ✨
https://codesandbox.io/s/Wp5OlNMn
MIT License
1.27k stars 89 forks source link

[v4] Error with github URLs #142

Closed ibc closed 8 years ago

ibc commented 8 years ago

I've not yet applied latest cmmit https://github.com/ritz078/embed.js/commit/8cb52a8369e33aa3621a42b5449d74d63dd65d9a, but I don't think this is related.

"Sometimes" (50% of them) when I paste a Github URL I get this error:

Uncaught (in promise) TypeError: Cannot read property 'avatar_url' of undefined

For example this one:

https://github.com/versatica/jssip/issues

It happens here:

key: 'github',
value: function github(data, options) {
    return '<div class="ejs-embed ejs-github"><div class="ejs-ogp-thumb" style="background-image:url(' + data.owner.avatar_url + ')"></div><div class="ejs-ogp-details"><div class="ejs-ogp-title"><a href="' + data.html_url + '" target="' + options.linkOptions.target + '">' + data.full_name + '</a></div><div class="ejs-ogb-details">' + data.description + '</div><div class="ejs-github-stats"><span><i class="fa fa-star"></i>' + data.stargazers_count + '</span><span><i class="fa fa-code-fork"></i>' + data.network_count + '</span></div></div></div>';
}

My usage is:

var x = new embed(
{
    input       : paragraphElem,
    link        : true,
    linkOptions :
    {
        target    : 'blank'
    },
    emoji       : true,
    fontIcons   : true
});

I don't want special stuff for Github links, should I disable something? I don't find anything in the doc. Well, I see this:

 openGraphExclude : ['youtube', 'github'],

but nowhere it is explained what github is...

ibc commented 8 years ago

Ok, similar error if I write a youtube URL...

Uncaught (in promise) TypeError: Cannot read property '0' of undefined(…)

ibc commented 8 years ago

I've set openGraphExclude : ['youtube', 'github'], and get the same issues... What should I disable to avoid these problems?

ritz078 commented 8 years ago

I think this should help http://codepen.io/ritz078/pen/rxbGQE

ibc commented 8 years ago

Please, just remove inlineEmbed:'all' and see what happens (also open the browser console)

ritz078 commented 8 years ago

check now.

ibc commented 8 years ago

It fixes the github problem. The youtube one remains:

http://codepen.io/anon/pen/MKROpW

Uncaught (in promise) TypeError: Cannot read property '0' of undefined
    at https://rawgit.com/ritz078/embed.js/feat/v4/dist/embed.min.js:10:13192