Merge branch 'master' of https://github.com/openstyles/stylus into dev-refactor

This commit is contained in:
eight 2018-10-30 15:10:40 +08:00
commit a76ec7c311
3 changed files with 20 additions and 1 deletions

View File

@ -253,6 +253,7 @@ const styleManager = (() => {
if (style.id == null) {
delete style.id;
}
fixUsoMd5Issue(style);
return db.exec('put', style)
.then(event => {
if (style.id == null) {
@ -380,6 +381,7 @@ const styleManager = (() => {
return;
}
for (const style of styleList) {
fixUsoMd5Issue(style);
styles.set(style.id, {
appliesTo: new Set(),
data: style
@ -479,4 +481,12 @@ const styleManager = (() => {
function getUrlNoHash(url) {
return url.split('#')[0];
}
// 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');
}
}
})();

View File

@ -159,7 +159,7 @@ API_METHODS.styleViaAPI = !CHROME && (() => {
return;
}
const tabFrames = cache.get(tabId);
if (frameId in tabFrames) {
if (tabFrames && frameId in tabFrames) {
delete tabFrames[frameId];
if (isEmpty(tabFrames)) {
onTabRemoved(tabId);

View File

@ -218,6 +218,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'})
@ -236,6 +244,7 @@
return style;
});
})
.then(tryFixMd5)
.catch(() => null);
}