<commit_before>#
# Redirect unsupported browsers to an unsupported browser page
#
{ parse } = require 'url'
uaParser = require 'ua-parser'

isUnsupported = (ua, req) ->
  not req.cookies.continue_with_bad_browser and ((ua.family is 'IE' and ua.major <=11) or (ua.family is 'Safari' and ua.major < 10))

getRedirectTo = (req) ->
  req.body['redirect-to'] or req.query['redirect-to'] or req.query['redirect_uri'] or parse(req.get('Referrer') or '').path or '/'

module.exports = (req, res, next) ->
  ua = uaParser.parseUA req.headers['user-agent']
  res.locals.sd.BROWSER = ua unless res.locals.sd.BROWSER
  if isUnsupported(ua, req) and not /\/unsupported-browser|assets|fonts|images/.test(req.path)
    res.locals.sd.UNSUPPORTED_BROWSER_REDIRECT = getRedirectTo req<commit_msg>[Supported Browsers] Move safari 10 to unsupported<commit_after>#
# Redirect unsupported browsers to an unsupported browser page
#
{ parse } = require 'url'
uaParser = require 'ua-parser'

isUnsupported = (ua, req) ->
  not req.cookies.continue_with_bad_browser and ((ua.family is 'IE' and ua.major <=11) or (ua.family is 'Safari' and ua.major <= 10))

getRedirectTo = (req) ->
  req.body['redirect-to'] or req.query['redirect-to'] or req.query['redirect_uri'] or parse(req.get('Referrer') or '').path or '/'

module.exports = (req, res, next) ->
  ua = uaParser.parseUA req.headers['user-agent']
  res.locals.sd.BROWSER = ua unless res.locals.sd.BROWSER
  if isUnsupported(ua, req) and not /\/unsupported-browser|assets|fonts|images/.test(req.path)
    res.locals.sd.UNSUPPORTED_BROWSER_REDIRECT = getRedirectTo req
{'fraction_non_alphanumeric': 0.14868255959849436, 'fraction_numerical': 0.006273525721455458, 'mean_word_length': 4.6761565836298935, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2577', 'n_tokens_mistral': 585, 'n_tokens_neox': 564, 'n_words': 137}