mirror of
https://github.com/discourse/discourse.git
synced 2024-11-27 10:06:17 +08:00
REFACTOR: improve readability of cacheBuster
This commit is contained in:
parent
30e9112535
commit
b2f556232f
|
@ -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}`;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user