spee.ch/server/controllers/api/oEmbed/parseSpeechUrl.js
2018-07-30 16:50:36 -07:00

24 lines
467 B
JavaScript

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;