working on regex

This commit is contained in:
bill bittner 2018-07-27 18:40:57 -07:00
parent 67e7a6f5b9
commit 3d7fa83e78
2 changed files with 69 additions and 17 deletions

View file

@ -80,3 +80,21 @@ Issues with lbry (e.g. the spee.ch wallet, lbrynet configuration, etc.) that req
* client
* [react](https://reactjs.org/)
### URL formats
Below is a list of all possible urls for the content on spee.ch
* controlling, free `LBRY` claim
* spee.ch/claim (show)
* spee.ch/claim.ext (serve)
* specific `LBRY` claim
* spee.ch/claim_id/claim
* spee.ch/claim_id/claim.ext
* all free contents for the controlling `LBRY` channel
* spee.ch/@channel
* a specific `LBRY` channel
* spee.ch/@channel:channel_id
* a specific claim within the controlling `LBRY` channel
* spee.ch/@channel/claim (show)
* spee.ch/@channel/claim.ext (serve)
* a specific claim within a specific `LBRY` channel
* spee.ch/@channel:channel_id/claim
* spee.ch/@channel:channel_id/claim.ext

View file

@ -2,27 +2,61 @@ const logger = require('winston');
const db = require('../../../models');
const getOEmbedData = (req, res) => {
logger.debug('req', req.query);
const CHANNEL_CHAR = '@';
const { query: { url, format } } = req;
logger.debug('req url', url);
logger.debug('req format', format);
// parse the request url
const componentsRegex = new RegExp(
'([^:/?#]+:\/\/)'+
'([^/?#]*)' +
'(\/)' +
'([^?#]*)' +
'(\/)' +
'([^?#]*)'
);
const [proto, protocol, domain, slashOne, paramOne, slashTwo, paramTwo] = componentsRegex
.exec(url)
.map(match => match || null);
logger.debug(`${protocol}, ${domain}, ${slashOne}, ${paramOne}, ${slashTwo}, ${paramTwo}`);
// parse the request url's pieces
// is there an identifier?
// if there is an identifier, is it a channel or a claim_id?
// if it is a channel, does it have a channel id?
// if no identifier, is the claim a channel?
// get the data
const data = {
version: 1.0 ,
author_name: 'Spee.ch',
author_url: 'https://spee.ch',
provider_name: 'Spee.ch',
provider_url: 'https://spee.ch',
cache_age: 86400, // one day in seconds
};
// set type
// if (fileType.substring(0, fileType.indexOf('/') === 'video')) {
// data['type'] = 'video';
// } else {
// data['type'] = 'picture';
// }
data['title'] = '';
data['thumbnail_url'] = '';
data['thumbnail_width'] = '';
data['thumbnail_height'] = '';
res.status(200).json({
success: true,
message: 'hello',
data: req.query,
data,
});
// 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;