Skip to content

Commit d016a8c

Browse files
MV88dsuren1
authored andcommitted
Fix geosolutions-it#10893 Making sure scripts from extensions are not cached (geosolutions-it#10895)
* Fix geosolutions-it#10893 Making sure scripts from extensions are not cached * update loadPlugin --------- Co-authored-by: Suren <dsuren1@gmail.com>
1 parent d704a44 commit d016a8c

2 files changed

Lines changed: 4 additions & 3 deletions

File tree

web/client/components/app/withExtensions.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ function withExtensions(AppComponent) {
137137
castArray(translationsPath).filter(p => p !== this.getAssetPath(translations)));
138138
}
139139
// remove the script element associated with the plugin, if it exists
140-
const script = document.querySelector(`script[src="${this.getAssetPath(plugin)}/index.js"]`);
140+
const script = document.querySelector(`script[src^="${this.getAssetPath(plugin)}/index.js"]`);
141141
script && script.remove();
142142
};
143143

web/client/utils/PluginsUtils.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import curry from 'lodash/curry';
1515
import {combineEpics as originalCombineEpics} from 'redux-observable';
1616
import {combineReducers as originalCombineReducers} from 'redux';
1717
import {wrapEpics} from "./EpicsUtils";
18+
import { randomInt } from './RandomUtils';
1819

1920
/**
2021
* Loads a script inside the current page.
@@ -25,7 +26,7 @@ function loadScript(src) {
2526
const s = document.createElement('script');
2627
let r = false;
2728
s.type = 'text/javascript';
28-
s.src = src;
29+
s.src = src + "?v=" + randomInt();
2930
s.async = true;
3031
s.onerror = function(err) {
3132
reject(err, s);
@@ -626,7 +627,7 @@ export const createPlugin = (name, { component, options = {}, containers = {}, r
626627
* @returns {Promise} a Promise that resolves to a lazy plugin object.
627628
*/
628629
export const loadPlugin = (pluginUrl, pluginName) => {
629-
const script = document.querySelector(`script[src="${pluginUrl}"]`);
630+
const script = document.querySelector(`script[src^="${pluginUrl}"]`);
630631
// load the script if not already loaded
631632
const load = script ? Promise.resolve() : loadScript(pluginUrl);
632633
return load

0 commit comments

Comments
 (0)