From 4852c1d667ec537639de2a07a8b2ec771413b760 Mon Sep 17 00:00:00 2001 From: Chetan P Jain Date: Mon, 1 Apr 2019 17:10:24 +0530 Subject: [PATCH] add code to include facebook embed --- lib/embed.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) 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) }) };