feat: Use prettier-eslint to format code
This commit is contained in:
committed by
mrugesh mohapatra
parent
1ba67c4e2b
commit
b13e5fb41a
@ -11,11 +11,7 @@ const pathsOfNoReturn = [
|
||||
'css'
|
||||
];
|
||||
|
||||
const pathsWhiteList = [
|
||||
'challenges',
|
||||
'map',
|
||||
'commit'
|
||||
];
|
||||
const pathsWhiteList = ['challenges', 'map', 'commit'];
|
||||
|
||||
const pathsOfNoReturnRegex = new RegExp(pathsOfNoReturn.join('|'), 'i');
|
||||
const whiteListRegex = new RegExp(pathsWhiteList.join('|'), 'i');
|
||||
@ -33,9 +29,9 @@ export default function addReturnToUrl() {
|
||||
) {
|
||||
return next();
|
||||
}
|
||||
req.session.returnTo = req.originalUrl.includes('/map') ?
|
||||
'/' :
|
||||
req.originalUrl;
|
||||
req.session.returnTo = req.originalUrl.includes('/map')
|
||||
? '/'
|
||||
: req.originalUrl;
|
||||
return next();
|
||||
};
|
||||
}
|
||||
|
@ -1,7 +1,8 @@
|
||||
export default function constantHeaders() {
|
||||
return function(req, res, next) {
|
||||
res.header('Access-Control-Allow-Origin', '*');
|
||||
res.header('Access-Control-Allow-Headers',
|
||||
res.header(
|
||||
'Access-Control-Allow-Headers',
|
||||
'Origin, X-Requested-With, Content-Type, Accept'
|
||||
);
|
||||
next();
|
||||
|
@ -3,7 +3,7 @@ import helmet from 'helmet';
|
||||
import { homeLocation } from '../../../config/env';
|
||||
|
||||
let trusted = [
|
||||
'\'self\'',
|
||||
"'self'",
|
||||
'https://search.freecodecamp.org',
|
||||
homeLocation,
|
||||
'https://' + process.env.AUTH0_DOMAIN
|
||||
@ -31,8 +31,8 @@ export default function csp() {
|
||||
'https://*.algolia.net'
|
||||
]),
|
||||
scriptSrc: [
|
||||
'\'unsafe-eval\'',
|
||||
'\'unsafe-inline\'',
|
||||
"'unsafe-eval'",
|
||||
"'unsafe-inline'",
|
||||
'*.google-analytics.com',
|
||||
'*.gstatic.com',
|
||||
'https://*.cloudflare.com',
|
||||
@ -48,7 +48,7 @@ export default function csp() {
|
||||
'*.ytimg.com'
|
||||
].concat(trusted),
|
||||
styleSrc: [
|
||||
'\'unsafe-inline\'',
|
||||
"'unsafe-inline'",
|
||||
'*.gstatic.com',
|
||||
'*.googleapis.com',
|
||||
'*.bootstrapcdn.com',
|
||||
|
@ -1,15 +1,12 @@
|
||||
import csurf from 'csurf';
|
||||
|
||||
export default function() {
|
||||
const protection = csurf(
|
||||
{
|
||||
cookie: {
|
||||
domain: process.env.COOKIE_DOMAIN || 'localhost'
|
||||
}
|
||||
const protection = csurf({
|
||||
cookie: {
|
||||
domain: process.env.COOKIE_DOMAIN || 'localhost'
|
||||
}
|
||||
);
|
||||
});
|
||||
return function csrf(req, res, next) {
|
||||
|
||||
const path = req.path.split('/')[1];
|
||||
if ((/(^api$|^unauthenticated$|^internal$|^p$)/).test(path)) {
|
||||
return next();
|
||||
|
@ -14,7 +14,9 @@ export default function flashCheaters() {
|
||||
if (
|
||||
ALLOWED_METHODS.indexOf(req.method) !== -1 &&
|
||||
EXCLUDED_PATHS.indexOf(req.path) === -1 &&
|
||||
req.user && req.url !== '/' && req.user.isCheater
|
||||
req.user &&
|
||||
req.url !== '/' &&
|
||||
req.user.isCheater
|
||||
) {
|
||||
req.flash(
|
||||
'danger',
|
||||
|
@ -20,11 +20,13 @@ export default function() {
|
||||
return false;
|
||||
}
|
||||
const keys = Object.keys(value);
|
||||
return !!keys.length &&
|
||||
return (
|
||||
!!keys.length &&
|
||||
// every key is a file
|
||||
keys.every(key => isObject(value[key])) &&
|
||||
// every file has contents
|
||||
keys.map(key => value[key]).every(file => isPoly(file));
|
||||
keys.map(key => value[key]).every(file => isPoly(file))
|
||||
);
|
||||
}
|
||||
},
|
||||
customSanitizers: {
|
||||
@ -32,16 +34,20 @@ export default function() {
|
||||
trimTags(value) {
|
||||
const tagBody = '(?:[^"\'>]|"[^"]*"|\'[^\']*\')*';
|
||||
const tagOrComment = new RegExp(
|
||||
'<(?:'
|
||||
// Comment body.
|
||||
+ '!--(?:(?:-*[^->])*--+|-?)'
|
||||
// Special "raw text" elements whose content should be elided.
|
||||
+ '|script\\b' + tagBody + '>[\\s\\S]*?</script\\s*'
|
||||
+ '|style\\b' + tagBody + '>[\\s\\S]*?</style\\s*'
|
||||
// Regular name
|
||||
+ '|/?[a-z]'
|
||||
+ tagBody
|
||||
+ ')>',
|
||||
'<(?:' +
|
||||
// Comment body.
|
||||
'!--(?:(?:-*[^->])*--+|-?)' +
|
||||
// Special "raw text" elements whose content should be elided.
|
||||
'|script\\b' +
|
||||
tagBody +
|
||||
'>[\\s\\S]*?</script\\s*' +
|
||||
'|style\\b' +
|
||||
tagBody +
|
||||
'>[\\s\\S]*?</style\\s*' +
|
||||
// Regular name
|
||||
'|/?[a-z]' +
|
||||
tagBody +
|
||||
')>',
|
||||
'gi'
|
||||
);
|
||||
let rawValue;
|
||||
|
Reference in New Issue
Block a user