Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
app.use(async (req, res, next) => {
res.locals.app = await application.getAll();
res.locals.app.url = `${req.protocol}://${req.headers.host}`;
// res.locals.github = await publisher('github').getAll();
// res.locals.gitlab = await publisher('gitlab').getAll();
res.locals.pub = await publication.getAll();
res.locals.session = req.session;
res.locals.timezones = timezones;
res.locals.languages = languages.getLanguages(languages.getAllCodes());
next();
});
import React from 'react';
import ISO6391 from 'iso-639-1';
import countries from 'svg-country-flags/countries.json';
import tags from './tags';
const languages = ISO6391.getLanguages(ISO6391.getAllCodes());
const emailPattern = /^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
const urlPattern = /^https:\/\/(www\.)?[-a-zA-Z0-9@:%._+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_+.~#?&//=]*)$/;
const linkedinPattern = /^[A-Za-z0-9-]{3,100}$/;
const facebookPattern = /^[a-z\d.]{5,50}$/i;
const twitterPattern = /^[A-Za-z0-9_]{1,15}$/;
const githubPattern = /^([a-z\d]+-)*[a-z\d]+$/i;
const emailValidation = value => !value || emailPattern.test(value);
const urlValidation = value => !value || urlPattern.test(value);
const linkedinValidation = value => !value || linkedinPattern.test(value);
const facebookValidation = value => !value || facebookPattern.test(value);
const twitterValidation = value => !value || twitterPattern.test(value);
const githubValidation = value => !value || githubPattern.test(value);
const nameValidation = value =>
value.length > 3 && value.length <= 50 && /^\S+(\s\S+)+$/.test(value);
export const getAllLanguages = () => {
const isoLanguages = ISO6391.getLanguages(ISO6391.getAllCodes());
const languagesWithoutRemoved = removeLanguages(isoLanguages);
const allLanguages = addAdditionalLanguages(languagesWithoutRemoved);
const allLanguagesSorted = allLanguages.sort((a, b) => {
if (a.name < b.name) return -1;
if (a.name > b.name) return 1;
return 0;
});
return allLanguagesSorted;
};