1
0

JavaScriptSourceMaps.php 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors
  5. * SPDX-License-Identifier: AGPL-3.0-or-later
  6. */
  7. namespace OCA\Settings\SetupChecks;
  8. use OCP\Http\Client\IClientService;
  9. use OCP\IConfig;
  10. use OCP\IL10N;
  11. use OCP\IURLGenerator;
  12. use OCP\SetupCheck\ISetupCheck;
  13. use OCP\SetupCheck\SetupResult;
  14. use Psr\Log\LoggerInterface;
  15. /**
  16. * Checks if the webserver serves '.map' files using the correct MIME type
  17. */
  18. class JavaScriptSourceMaps implements ISetupCheck {
  19. use CheckServerResponseTrait;
  20. public function __construct(
  21. protected IL10N $l10n,
  22. protected IConfig $config,
  23. protected IURLGenerator $urlGenerator,
  24. protected IClientService $clientService,
  25. protected LoggerInterface $logger,
  26. ) {
  27. }
  28. public function getCategory(): string {
  29. return 'network';
  30. }
  31. public function getName(): string {
  32. return $this->l10n->t('JavaScript source map support');
  33. }
  34. public function run(): SetupResult {
  35. $testFile = $this->urlGenerator->linkTo('settings', 'js/map-test.js.map');
  36. foreach ($this->runHEAD($testFile) as $response) {
  37. return SetupResult::success();
  38. }
  39. return SetupResult::warning($this->l10n->t('Your webserver is not set up to serve `.js.map` files. Without these files, JavaScript Source Maps won\'t function properly, making it more challenging to troubleshoot and debug any issues that may arise.'));
  40. }
  41. }