<commit_before>'use strict'
// **Github:** https://github.com/toajs/toa-cookie-session
//
// **License:** MIT

const _isSameSiteNoneCompatible = require('should-send-same-site-none').isSameSiteNoneCompatible

module.exports = toaCookieSession

function toaCookieSession (options) {
  options = options || {}
  options.overwrite = options.overwrite !== false
  options.httpOnly = options.httpOnly !== false
  options.signed = options.signed !== false

  const sessionKey = options.name || 'toa:sess'
  const setCookie = options.setCookie !== false

  return function cookieSession () {
    let session = false
    if (options.sameSite && typeof options.sameSite === 'string' && options.sameSite.toLowerCase() === 'none') {
      const userAgent = this.get('user-agent')
      // Non-secure context or Incompatible clients, don't send SameSite=None property
      if (!options.secure || (userAgent && !isSameSiteNoneCompatible(userAgent))) {
        options.sameSite = false
      }
    }

    this.sessionOptions = Object.create(options)

    Object.defineProperty(this, 'session', {
      enumerable: true,
      configurable: false,
      get: function () {
        if (session === false) {<commit_msg>fix: sameSite option reset<commit_after>'use strict'
// **Github:** https://github.com/toajs/toa-cookie-session
//
// **License:** MIT

const _isSameSiteNoneCompatible = require('should-send-same-site-none').isSameSiteNoneCompatible

module.exports = toaCookieSession

function toaCookieSession (options) {
  options = options || {}
  options.overwrite = options.overwrite !== false
  options.httpOnly = options.httpOnly !== false
  options.signed = options.signed !== false

  const sessionKey = options.name || 'toa:sess'
  const setCookie = options.setCookie !== false

  return function cookieSession () {
    let session = false
    this.sessionOptions = Object.create(options)

    if (options.sameSite && typeof options.sameSite === 'string' && options.sameSite.toLowerCase() === 'none') {
      const userAgent = this.get('user-agent')
      // Non-secure context or Incompatible clients, don't send SameSite=None property
      if (!options.secure || (userAgent && !isSameSiteNoneCompatible(userAgent))) {
        this.sessionOptions.sameSite = false
      }
    }

    Object.defineProperty(this, 'session', {
      enumerable: true,
      configurable: false,
      get: function () {
        if (session === false) {
{'fraction_non_alphanumeric': 0.134923899629782, 'fraction_numerical': 0.0, 'mean_word_length': 3.6859344894026975, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '3965264', 'n_tokens_mistral': 693, 'n_tokens_neox': 686, 'n_words': 157}