REFACTOR: improve readability of cacheBuster

This commit is contained in:
jbrw 2020-09-14 16:46:17 -04:00
parent 30e9112535
commit b2f556232f
No known key found for this signature in database
GPG Key ID: AF11336DC5C6EC71

View File

@ -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}`;
}
}