fixed regex and oebed url creator
This commit is contained in:
parent
99cdfc0c8d
commit
67e7a6f5b9
4 changed files with 35 additions and 4 deletions
|
@ -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
|
||||
};
|
||||
};
|
||||
|
|
|
@ -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,
|
||||
};
|
||||
};
|
||||
|
|
28
server/controllers/api/oEmbed/index.js
Normal file
28
server/controllers/api/oEmbed/index.js
Normal file
|
@ -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;
|
|
@ -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)
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue