From ad2727aef847ef8a6f276386294f8a248671d80a Mon Sep 17 00:00:00 2001
From: Ferdinand Thiessen <opensource@fthiessen.de>
Date: Tue, 18 Jul 2023 13:09:30 +0200
Subject: fix: Correctly add `module` content type to script tags when scripts
 with versions are used

Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
---
 lib/private/legacy/template/functions.php | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

(limited to 'lib')

diff --git a/lib/private/legacy/template/functions.php b/lib/private/legacy/template/functions.php
index 7081bd4f743..0d386625ab3 100644
--- a/lib/private/legacy/template/functions.php
+++ b/lib/private/legacy/template/functions.php
@@ -101,7 +101,8 @@ function emit_script_tag(string $src, string $script_content = '', string $conte
  */
 function emit_script_loading_tags($obj) {
 	foreach ($obj['jsfiles'] as $jsfile) {
-		$type = str_ends_with($jsfile, '.mjs') ? 'module' : '';
+		$fileName = explode('?', $jsfile, 2)[0];
+		$type = str_ends_with($fileName, '.mjs') ? 'module' : '';
 		emit_script_tag($jsfile, '', $type);
 	}
 	if (!empty($obj['inline_ocjs'])) {
-- 
cgit v1.2.3