UNPKG

coach-core

Version:
49 lines (42 loc) 1.46 kB
(function () { 'use strict'; const url = document.URL; let score = 100; let message = ''; // ok all Java lovers, please do not use the sessionid in your URLs if (url.includes('?') && url.indexOf('jsessionid') > url.indexOf('?')) { score = 0; message = 'The page has the session id for the user as a parameter, please change so the session handling is done only with cookies. '; } var parameters = (url.match(/&/g) || []).length; if (parameters > 1) { score -= 50; message += 'The page is using more than two request parameters. You should really rethink and try to minimize the number of parameters. '; } if (url.length > 100) { score -= 10; message += 'The URL is ' + url.length + ' characters long. Try to make it less than 100 characters. '; } if (url.includes(' ') || url.includes('%20')) { score -= 10; message += 'Could the developer or the CMS be on Windows? Avoid using spaces in the URLs, use hyphens or underscores. '; } return { id: 'url', title: 'Have a good URL format', description: 'A clean URL is good for the user and for SEO. Make them human readable, avoid too long URLs, spaces in the URL, too many request parameters, and never ever have the session id in your URL.', advice: message, score: Math.max(score, 0), weight: 2, severity: 'info', offending: [], tags: ['bestpractice'] }; })();