Skip to content

Commit d3f0fc8

Browse files
authored
fix: correct oembed frame source (#285)
1 parent ea397df commit d3f0fc8

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

src/lambda/oembed/oembed.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ function handler(event, context, callback) {
3535
}
3636

3737
const { url, referrer, maxwidth = 900, maxheight = 300 } = params;
38-
const iframeSrc = `${url.replace('gist', 'embed')}?panes=preview,result`;
3938

4039
callback(null, {
4140
statusCode: 200,
@@ -48,7 +47,7 @@ function handler(event, context, callback) {
4847
provider_name: 'testing-playground.com',
4948
provider_url: host,
5049

51-
html: `<iframe src="${iframeSrc}" height="${maxheight}" width="${maxwidth}" scrolling="no" frameBorder="0" allowTransparency="true" title="Testing Playground" style="overflow: hidden; display: block; width: 100%"></iframe>`,
50+
html: `<iframe src="${url}" height="${maxheight}" width="${maxwidth}" scrolling="no" frameBorder="0" allowTransparency="true" title="Testing Playground" style="overflow: hidden; display: block; width: 100%"></iframe>`,
5251
width: maxwidth,
5352
height: maxheight,
5453

src/lambda/server/server.js

+8-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,12 @@ const path = require('path');
33
const queryString = require('query-string');
44

55
const filename = path.join(__dirname, './index.html');
6-
const indexHtml = fs.readFileSync(filename, 'utf8');
6+
const indexHtml = fs.existsSync(filename)
7+
? fs.readFileSync(filename, 'utf8')
8+
: fs.readFileSync(
9+
path.join(__dirname, '../../../dist/client/index.html'),
10+
'utf8',
11+
);
712

813
function getHostname(event, context) {
914
if (event.headers.host) {
@@ -19,7 +24,8 @@ function handler(event, context, callback) {
1924
const { panes, markup, query } = event.queryStringParameters;
2025
const host = getHostname(event, context);
2126

22-
const frameSrc = `${host}/embed?${queryString.stringify({
27+
const embedPath = event.path.replace('/gist/', '/embed/');
28+
const frameSrc = `${host}${embedPath}?${queryString.stringify({
2329
panes,
2430
markup,
2531
query,

0 commit comments

Comments
 (0)