Skip to content

Commit

Permalink
Merge pull request #46302 from nextcloud/fix/noid/jsm-check-pickiness
Browse files Browse the repository at this point in the history
[stable28] fix(SetupCheck): jsm test shall not give up with first no-response
  • Loading branch information
solracsf authored Jul 9, 2024
2 parents 19ab1ff + fa55d97 commit e395d1f
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion apps/settings/lib/SetupChecks/JavaScriptModules.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ public function run(): SetupResult {
array_map(fn (string $host): string => $host . $testFile, $this->config->getSystemValue('trusted_domains', []))
);

$gotResponse = false;
foreach ($testURLs as $testURL) {
try {
$client = $this->clientService->newClient();
Expand All @@ -73,14 +74,17 @@ public function run(): SetupResult {
'allow_local_address' => true,
],
]);
$gotResponse = true;
if (preg_match('/(text|application)\/javascript/i', $response->getHeader('Content-Type'))) {
return SetupResult::success();
}
} catch (\Throwable $e) {
$this->logger->debug('Can not connect to local server for checking JavaScript modules support', ['exception' => $e, 'url' => $testURL]);
return SetupResult::warning($this->l10n->t('Could not check for JavaScript support. Please check manually if your webserver serves `.mjs` files using the JavaScript MIME type.'));
}
}
if (!$gotResponse) {
return SetupResult::warning($this->l10n->t('Could not check for JavaScript support. Please check manually if your webserver serves `.mjs` files using the JavaScript MIME type.'));
}
return SetupResult::error($this->l10n->t('Your webserver does not serve `.mjs` files using the JavaScript MIME type. This will break some apps by preventing browsers from executing the JavaScript files. You should configure your webserver to serve `.mjs` files with either the `text/javascript` or `application/javascript` MIME type.'));
}
}

0 comments on commit e395d1f

Please sign in to comment.