diff --git a/lib/embed.js b/lib/embed.js index de3c959..1fe52d6 100644 --- a/lib/embed.js +++ b/lib/embed.js @@ -22,6 +22,18 @@ function createTwitterEmbed ({url}) { }; } +function getUrlParameter(url, name) { + name = name.replace(/[\[]/, '\\[').replace(/[\]]/, '\\]'); + var regex = new RegExp('[\\?&]' + name + '=([^&#]*)'); + var results = regex.exec(url); + return results === null ? '' : decodeURIComponent(results[1].replace(/\+/g, ' ')); +} + +function formatFacebookUrl(url) { + var url = getUrlParameter(url, 'href'); + return url; +} + const embeds = { instagram: ({id}) => ({ role: 'instagram', @@ -40,6 +52,10 @@ const embeds = { image: ({src}) => ({ role: 'photo', URL: src + }), + facebook: ({src}) => ({ + role: 'facebook', + URL: formatFacebookUrl(src) }) };