luci-app-dockerman: jsmin workaround
authorPaul Donald <newtwen+github@gmail.com>
Thu, 5 Feb 2026 17:06:43 +0000 (18:06 +0100)
committerPaul Donald <newtwen+github@gmail.com>
Thu, 5 Feb 2026 17:09:15 +0000 (18:09 +0100)
jsmin state machine is basic so it fails on this:

return /^https?:\/\//i.test(addr)

interpreting the final // as comment start, not recognizing
it is in a regex. But if we wrap the regex in () then all
is well. jsmin has the comment:

action recognizes a regular expression if it is preceded by the likes of
'(' or ',' or '='.

Signed-off-by: Paul Donald <newtwen+github@gmail.com>
applications/luci-app-dockerman/htdocs/luci-static/resources/dockerman/common.js

index 688212bb7fb9f469c3863c5e0a8456715fc62af4..9cc092dcacc72f22608663325b7a91d86eeb100b 100644 (file)
@@ -742,7 +742,10 @@ const dv = view.extend({
        ensureRegistryScheme(address, hostFallback) {
                const addr = String(address || '').trim() || hostFallback;
                if (!addr) return null;
-               return /^https?:\/\//i.test(addr) ? addr : `https://${addr}`;
+               /* jsmin cannot handle /^https?:\/\//i.test(addr) - wrap in parentheses: OK
+               https = new RegExp('https?:\/\/', 'i'); // also OK
+                */
+               return (/^https?:\/\//i.test(addr)) ? addr : `https://${addr}`;
        },
 
        /**