[feature] Use location.pathname to find worker version

This commit is contained in:
Sergey Konovalov
2024-08-22 19:59:50 +03:00
parent 6840117a31
commit 31f74eb3a1

View File

@ -395,10 +395,14 @@ docsCoServer.install(server, () => {
});
app.get('/serviceworker.js', apicache.middleware("60 minutes"), async (req, res) => {
//todo put serviceworker.js in sdkjs and change location in nginx config
let content = `const g_version = '${commonDefines.buildVersion}-${commonDefines.buildNumber}';
let content = `let g_version = "unknown";//unknown for develop
let pathnameParts = self.location.pathname.split('/');
if (pathnameParts.length > 1 && pathnameParts[pathnameParts.length - 2]) {
g_version = pathnameParts[pathnameParts.length - 2];
}
const g_cacheNamePrefix = 'document_editor_static_';
const g_cacheName = g_cacheNamePrefix + g_version;
const patternPrefix = new RegExp(g_version + "\\\\w*/(web-apps|sdkjs|sdkjs-plugins|fonts|dictionaries)");
const patternPrefix = new RegExp(g_version + "/(web-apps|sdkjs|sdkjs-plugins|fonts|dictionaries)");
const putInCache = async (request, response) => {
\tconst cache = await caches.open(g_cacheName);