Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 | 1x 1x 1x 1x 1x 1x 1x 16x 16x 16x 16x 2x 2x 16x 14x 14x 16x 13x 13x 13x 16x 10x 10x 10x 10x 10x 10x 10x 10x 10x 13x 1x 1x 1x 1x 1x 1x 1x 1x 1x | const R = require('ramda');
const { URL } = require('url');
const PublicationInformation = require('./PublicationInformation.js');
const publicationInformation = new PublicationInformation();
module.exports = function (inputUrl) {
let url;
try {
url = new URL(inputUrl);
} catch(e) {
return; //Nothing more to do here!
}
if (!url || !url.hostname || !url.pathname) return;
console.log(url.hostname);
const values = publicationInformation.findHostname(url.hostname);
if (!values) return;
//eslint doesn't handle regex well
//eslint-disable-next-line no-useless-escape
const channelMatch = url.pathname.match(/\/([^\/]+)\//);
if (channelMatch && channelMatch[1]) {
values.channel = channelMatch[1];
//Should always exist given the above
//eslint-disable-next-line no-useless-escape
values.section = R.reverse(R.reverse(url.pathname).match(/\/([^\/]+)/)[1]);
values.fullSection = url.pathname.split('/').slice(1,-1).join('/');
//reverse here to avoid regex DOS
const articleIdMatch = R.reverse(url.pathname.replace(/\.amp/, '')).match(/^([0-9]+)-/);
if (articleIdMatch && articleIdMatch[1]) values.articleId = R.reverse(articleIdMatch[1]);
}
return values;
};
module.exports.nameLookUp = name => publicationInformation.findName(name);
module.exports.idLookUp = (platform, id) => publicationInformation.findId(platform, id);
module.exports.publicationInfo = () => {
return publicationInformation.clone();
};
|