REFACTOR: improve readability of cacheBuster

REFACTOR: improve readability of cacheBuster

diff --git a/app/assets/javascripts/discourse/app/lib/load-script.js b/app/assets/javascripts/discourse/app/lib/load-script.js
index a766581..c5b87ca 100644
--- a/app/assets/javascripts/discourse/app/lib/load-script.js
+++ b/app/assets/javascripts/discourse/app/lib/load-script.js
@@ -110,10 +110,11 @@ export default function loadScript(url, opts) {
 
 export function cacheBuster(url) {
   if (PUBLIC_JS_VERSIONS) {
-    const pathParts = url.split("/");
-    if (pathParts[1] === "javascripts") {
-      const version = PUBLIC_JS_VERSIONS[pathParts[2]];
-      if (typeof version !== "undefined") {
+    // eslint-disable-next-line no-unused-vars
+    const [_, folder, lib] = url.split("/");
+    if (folder === "javascripts") {
+      const version = PUBLIC_JS_VERSIONS[lib];
+      if (version) {
         return `${url}?v=${version}`;
       }
     }

GitHub sha: b2f55623

1 Like