spee.ch/server/controllers/api/oEmbed/parseSpeechUrl.js

25 lines
467 B
JavaScript
Raw Normal View History

2018-07-31 01:50:36 +02:00
const logger = require('winston');
const parseSpeechUrl = (url) => {
const componentsRegex = new RegExp(
'([^:/?#]+://)' +
'([^/?#]*)' +
'(/)' +
'([^/?#]*)' +
'(/)' +
'([^/?#]*)'
);
const [, , , , paramOne, , paramTwo] = componentsRegex
.exec(url)
.map(match => match || null);
logger.debug(`params from speech url: ${paramOne} ${paramTwo}`);
return {
paramOne,
paramTwo,
};
};
module.exports = parseSpeechUrl;