MOBILE-3072 siteplugins: Add version to CSS URL

main
Dani Palou 2019-07-15 11:38:52 +02:00
parent 79cfc44e0d
commit 8f8efe4052
2 changed files with 23 additions and 0 deletions

View File

@ -142,6 +142,11 @@ export class CoreSitePluginsHelperProvider {
url = this.textUtils.concatenatePaths(site.getURL(), url);
}
if (url && handlerSchema.styles.version) {
// Add the version to the URL to prevent getting a cached file.
url += (url.indexOf('?') != -1 ? '&' : '?') + 'version=' + handlerSchema.styles.version;
}
const uniqueName = this.sitePluginsProvider.getHandlerUniqueName(plugin, handlerName),
componentId = uniqueName + '#main';

View File

@ -2197,9 +2197,27 @@ export class CoreFilepoolProvider {
filename = this.urlUtils.getLastFileWithoutParams(fileUrl);
}
// If there are hashes in the URL, extract them.
const index = filename.indexOf('#');
let hashes;
if (index != -1) {
hashes = filename.split('#');
// Remove the URL from the array.
hashes.shift();
filename = filename.substr(0, index);
}
// Remove the extension from the filename.
filename = this.mimeUtils.removeExtension(filename);
if (hashes) {
// Add hashes to the name.
filename += '_' + hashes.join('_');
}
return this.textUtils.removeSpecialCharactersForFiles(filename);
}