class Bullet::Rack

def with_security_policy_nonce(headers)

def with_security_policy_nonce(headers)
  matched = (headers['Content-Security-Policy'] || '').match(NONCE_MATCHER)
  nonce = matched[:nonce] if matched
  if nonce
    console_enabled = UniformNotifier.console
    alert_enabled = UniformNotifier.alert
    UniformNotifier.console = { attributes: { nonce: nonce } } if console_enabled
    UniformNotifier.alert = { attributes: { nonce: nonce } } if alert_enabled
    yield nonce
    UniformNotifier.console = console_enabled
    UniformNotifier.alert = alert_enabled
  else
    yield
  end
end