* Fix incorrect USO md5Url (#523) * Fix md5Url in getAll * Remove variable reassignment
This commit is contained in:
parent
100e1dc28d
commit
30cf5b2458
|
@ -174,6 +174,7 @@ function getStyles(options) {
|
|||
|
||||
return dbExec('getAll').then(event => {
|
||||
cachedStyles.list = event.target.result || [];
|
||||
cachedStyles.list.forEach(fixUsoMd5Issue);
|
||||
cachedStyles.byId.clear();
|
||||
for (const style of cachedStyles.list) {
|
||||
cachedStyles.byId.set(style.id, style);
|
||||
|
@ -264,6 +265,14 @@ function filterStyles({
|
|||
}
|
||||
|
||||
|
||||
// The md5Url provided by USO includes a duplicate "update" subdomain (see #523),
|
||||
// This fixes any already installed styles containing this error
|
||||
function fixUsoMd5Issue(style) {
|
||||
if (style && style.md5Url && style.md5Url.includes('update.update.userstyles')) {
|
||||
style.md5Url = style.md5Url.replace('update.update.userstyles', 'update.userstyles');
|
||||
}
|
||||
}
|
||||
|
||||
function filterStylesInternal({
|
||||
// js engines don't like big functions (V8 often deoptimized the original filterStyles)
|
||||
// it also makes sense to extract the less frequently executed code
|
||||
|
@ -350,6 +359,8 @@ function saveStyle(style) {
|
|||
let existed;
|
||||
let codeIsUpdated;
|
||||
|
||||
fixUsoMd5Issue(style);
|
||||
|
||||
return maybeCalcDigest()
|
||||
.then(maybeImportFix)
|
||||
.then(decide);
|
||||
|
|
|
@ -238,6 +238,14 @@
|
|||
});
|
||||
}
|
||||
|
||||
// USO providing md5Url as "https://update.update.userstyles.org/#####.md5"
|
||||
// instead of "https://update.userstyles.org/#####.md5"
|
||||
function tryFixMd5(style) {
|
||||
if (style && style.md5Url && style.md5Url.includes('update.update')) {
|
||||
style.md5Url = style.md5Url.replace('update.update', 'update');
|
||||
}
|
||||
return style;
|
||||
}
|
||||
|
||||
function getStyleJson() {
|
||||
return getResource(getStyleURL(), {responseType: 'json'})
|
||||
|
@ -256,6 +264,7 @@
|
|||
});
|
||||
}));
|
||||
})
|
||||
.then(tryFixMd5)
|
||||
.catch(() => null);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user