<commit_before>(ns ring.middleware.flash
  "A session-based flash store that persists to the next request.")

(defn wrap-flash
  "If a :flash key is set on the response by the handler, a :flash key with
  the same value will be set on the next request that shares the same session.
  This is useful for small messages that persist across redirects."
  [handler]
  (fn [request]
    (let [session  (request :session)
          flash    (session :_flash)
          session  (dissoc session :_flash)
          request  (assoc request
                     :session session
                     :flash flash)
          response (handler request)
          session  (if-let [flash (response :flash)]
                     (assoc (response :session) :_flash flash))]
      (assoc response :session session))))<commit_msg>Keep from dropping sessions when the flash is not set.<commit_after>(ns ring.middleware.flash
  "A session-based flash store that persists to the next request.")

(defn wrap-flash
  "If a :flash key is set on the response by the handler, a :flash key with
  the same value will be set on the next request that shares the same session.
  This is useful for small messages that persist across redirects."
  [handler]
  (fn [request]
    (let [session  (request :session)
          flash    (session :_flash)
          session  (dissoc session :_flash)
          request  (assoc request
                     :session session
                     :flash flash)
          response (handler request)
          session  (if-let [flash (response :flash)]
                     (assoc (response :session) :_flash flash)
                     session)]
      (assoc response :session session))))
{'fraction_non_alphanumeric': 0.07488207547169812, 'fraction_numerical': 0.0, 'mean_word_length': 2.2697495183044314, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '3505703', 'n_tokens_mistral': 438, 'n_tokens_neox': 424, 'n_words': 195}