diff --git a/client/build/utils/oEmbed.js b/client/build/utils/oEmbed.js index a1d7c1ab..fc276f25 100644 --- a/client/build/utils/oEmbed.js +++ b/client/build/utils/oEmbed.js @@ -8,7 +8,7 @@ var rel = 'alternate'; var title = 'spee.ch oEmbed profile'; var formatUrlForQuery = function formatUrlForQuery(url) { - return url.replace(/\/+/, '%2F').replace(/:/, '%3A'); + return url.replace(/\//g, '%2F').replace(/:/g, '%3A'); }; var createJsonLinkData = function createJsonLinkData(host, canonicalUrl) { @@ -24,7 +24,7 @@ var createXmlLinkData = function createXmlLinkData(host, canonicalUrl) { return { rel: rel, type: 'application/xml+oembed', - href: "".concat(host, "/api/oembed?").concat(formatUrlForQuery(canonicalUrl), "%2F&format=xml"), + href: "".concat(host, "/api/oembed?url=").concat(formatUrlForQuery(canonicalUrl), "%2F&format=xml"), title: title }; }; diff --git a/client/src/utils/oEmbed.js b/client/src/utils/oEmbed.js index 9d8b2296..796df5e6 100644 --- a/client/src/utils/oEmbed.js +++ b/client/src/utils/oEmbed.js @@ -2,7 +2,7 @@ const rel = 'alternate'; const title = 'spee.ch oEmbed profile'; const formatUrlForQuery = (url) => { - return url.replace(/\/+/, '%2F').replace(/:/, '%3A'); + return url.replace(/\//g, '%2F').replace(/:/g, '%3A'); }; const createJsonLinkData = (host, canonicalUrl) => { @@ -18,7 +18,7 @@ const createXmlLinkData = (host, canonicalUrl) => { return { rel, type: 'application/xml+oembed', - href: `${host}/api/oembed?${formatUrlForQuery(canonicalUrl)}%2F&format=xml`, + href: `${host}/api/oembed?url=${formatUrlForQuery(canonicalUrl)}%2F&format=xml`, title, }; }; diff --git a/server/controllers/api/oEmbed/index.js b/server/controllers/api/oEmbed/index.js new file mode 100644 index 00000000..35182912 --- /dev/null +++ b/server/controllers/api/oEmbed/index.js @@ -0,0 +1,28 @@ +const logger = require('winston'); +const db = require('../../../models'); + +const getOEmbedData = (req, res) => { + logger.debug('req', req.query); + res.status(200).json({ + success: true, + message: 'hello', + data: req.query, + }); + // db.Blocked.refreshTable() + // .then(data => { + // logger.info('finished updating blocked content list'); + // res.status(200).json({ + // success: true, + // data, + // }); + // }) + // .catch(error => { + // logger.error(error); + // res.status(500).json({ + // success: false, + // error, + // }); + // }); +}; + +module.exports = getOEmbedData; diff --git a/server/routes/api/index.js b/server/routes/api/index.js index bb24e5b2..349e2ff3 100644 --- a/server/routes/api/index.js +++ b/server/routes/api/index.js @@ -19,6 +19,7 @@ const userPassword = require('../../controllers/api/user/password'); const publishingConfig = require('../../controllers/api/config/site/publishing'); const getTorList = require('../../controllers/api/tor'); const getBlockedList = require('../../controllers/api/blocked'); +const getOEmbedData = require('../../controllers/api/oEmbed'); module.exports = (app) => { @@ -46,4 +47,6 @@ module.exports = (app) => { app.get('/api/tor', torCheckMiddleware, getTorList); // blocked app.get('/api/blocked', torCheckMiddleware, getBlockedList); + // open embed + app.get('/api/oembed', torCheckMiddleware, getOEmbedData) };