<commit_before>const path = require('path')
const express = require('express')

const app = express()

const port = process.env.PORT ? process.env.PORT : 8081
const dist = path.join(__dirname, 'public')


app.use(express.static(dist))
app.all('*', function (req, res, next) { // eslint-disable-line
  if (req.headers['x-forwarded-proto'] === 'https') {
    return next()
  }
  res.redirect(`https://${req.headers.host}`)
})

app.get('*', (req, res) => {
  res.sendFile(path.join(dist, 'index.html'))
})<commit_msg>Fix ensure secure connection middleware<commit_after>const path = require('path')
const express = require('express')

const app = express()

const port = process.env.PORT ? process.env.PORT : 8081
const dist = path.join(__dirname, 'public')


function ensureSecure(req, res, next) { // eslint-disable-line
  if (req.secure) {
    return next()
  }

  res.redirect(`https://${req.hostname} ${req.url}`)
}

app.use(express.static(dist))
app.all('*', ensureSecure)

app.get('*', (req, res) => {
  res.sendFile(path.join(dist, 'index.html'))
})
{'fraction_non_alphanumeric': 0.19734345351043645, 'fraction_numerical': 0.007590132827324478, 'mean_word_length': 4.582010582010582, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 2, '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': '2513243', 'n_tokens_mistral': 372, 'n_tokens_neox': 363, 'n_words': 77}