<commit_before><?php

namespace Drupal\atm\Controller;

use Drupal\Core\Controller\ControllerBase;
use GuzzleHttp\Exception\ClientException;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpFoundation\ResponseHeaderBag;

/**
 * Provides routers for controller atm.
 */
class AtmApiController extends ControllerBase {

  /**
   * Redirect to atm.js.
   */
  public function getJs() {
    /** @var \Drupal\atm\Helper\AtmApiHelper $helper */
    $helper = \Drupal::service('atm.helper');
    $jsPath = $helper->get('build_path');

    $https = &$_SERVER['HTTPS'];

    if ($https == 'on') {
      $jsPath = preg_replace("/^http/", 'https', $jsPath);
    }

    return new RedirectResponse($jsPath);
  }

  /**<commit_msg>Check https for loading atm.js<commit_after><?php

namespace Drupal\atm\Controller;

use Drupal\Core\Controller\ControllerBase;
use GuzzleHttp\Exception\ClientException;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpFoundation\ResponseHeaderBag;

/**
 * Provides routers for controller atm.
 */
class AtmApiController extends ControllerBase {

  /**
   * Redirect to atm.js.
   */
  public function getJs() {
    /** @var \Drupal\atm\Helper\AtmApiHelper $helper */
    $helper = \Drupal::service('atm.helper');
    $jsPath = $helper->get('build_path');

    $isSecure = ((!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off') || $_SERVER['SERVER_PORT'] == 443);

    if ($isSecure) {
      $jsPath = preg_replace("/^http/", 'https', $jsPath);
    }

    return new RedirectResponse($jsPath);
  }

  /**
{'fraction_non_alphanumeric': 0.1510912143256855, 'fraction_numerical': 0.0016787912702853946, 'mean_word_length': 4.289940828402367, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '1348135', 'n_tokens_mistral': 563, 'n_tokens_neox': 558, 'n_words': 105}