From 742eb05d6b09d1dd8352eb841ed00fce41dd32af Mon Sep 17 00:00:00 2001 From: the1812 Date: Sat, 26 Oct 2019 11:02:17 +0800 Subject: [PATCH] Auto remove leading dot in image extension --- bilibili-evolved.offline.user.js | 3 +++ bilibili-evolved.preview-offline.user.js | 3 +++ bilibili-evolved.preview.user.js | 3 +++ bilibili-evolved.user.js | 3 +++ src/client/utils.js | 3 +++ 5 files changed, 15 insertions(+) diff --git a/bilibili-evolved.offline.user.js b/bilibili-evolved.offline.user.js index 65d6b2fd9..04907f526 100644 --- a/bilibili-evolved.offline.user.js +++ b/bilibili-evolved.offline.user.js @@ -154,6 +154,9 @@ const formatDuration = (time, fixed = 0) => { } const getDpiSourceSet = (src, baseSize, extension = 'jpg') => { const dpis = [1, 1.25, 1.5, 1.75, 2, 2.25, 2.5, 2.75, 3, 3.25, 3.5, 3.75, 4] + if (extension.startsWith('.')) { + extension = extension.substring(1) + } return dpis.map(dpi => { if (typeof baseSize === 'object') { if ('width' in baseSize && 'height' in baseSize) { diff --git a/bilibili-evolved.preview-offline.user.js b/bilibili-evolved.preview-offline.user.js index 3a2a35cd9..f3e3c9f10 100644 --- a/bilibili-evolved.preview-offline.user.js +++ b/bilibili-evolved.preview-offline.user.js @@ -154,6 +154,9 @@ const formatDuration = (time, fixed = 0) => { } const getDpiSourceSet = (src, baseSize, extension = 'jpg') => { const dpis = [1, 1.25, 1.5, 1.75, 2, 2.25, 2.5, 2.75, 3, 3.25, 3.5, 3.75, 4] + if (extension.startsWith('.')) { + extension = extension.substring(1) + } return dpis.map(dpi => { if (typeof baseSize === 'object') { if ('width' in baseSize && 'height' in baseSize) { diff --git a/bilibili-evolved.preview.user.js b/bilibili-evolved.preview.user.js index 4b1550c64..ec83365d0 100644 --- a/bilibili-evolved.preview.user.js +++ b/bilibili-evolved.preview.user.js @@ -153,6 +153,9 @@ const formatDuration = (time, fixed = 0) => { } const getDpiSourceSet = (src, baseSize, extension = 'jpg') => { const dpis = [1, 1.25, 1.5, 1.75, 2, 2.25, 2.5, 2.75, 3, 3.25, 3.5, 3.75, 4] + if (extension.startsWith('.')) { + extension = extension.substring(1) + } return dpis.map(dpi => { if (typeof baseSize === 'object') { if ('width' in baseSize && 'height' in baseSize) { diff --git a/bilibili-evolved.user.js b/bilibili-evolved.user.js index 595ae91ca..93c519de3 100644 --- a/bilibili-evolved.user.js +++ b/bilibili-evolved.user.js @@ -153,6 +153,9 @@ const formatDuration = (time, fixed = 0) => { } const getDpiSourceSet = (src, baseSize, extension = 'jpg') => { const dpis = [1, 1.25, 1.5, 1.75, 2, 2.25, 2.5, 2.75, 3, 3.25, 3.5, 3.75, 4] + if (extension.startsWith('.')) { + extension = extension.substring(1) + } return dpis.map(dpi => { if (typeof baseSize === 'object') { if ('width' in baseSize && 'height' in baseSize) { diff --git a/src/client/utils.js b/src/client/utils.js index 0c3b231db..e6dd2a453 100644 --- a/src/client/utils.js +++ b/src/client/utils.js @@ -117,6 +117,9 @@ export const formatDuration = (time, fixed = 0) => { } export const getDpiSourceSet = (src, baseSize, extension = 'jpg') => { const dpis = [1, 1.25, 1.5, 1.75, 2, 2.25, 2.5, 2.75, 3, 3.25, 3.5, 3.75, 4] + if (extension.startsWith('.')) { + extension = extension.substring(1) + } return dpis.map(dpi => { if (typeof baseSize === 'object') { if ('width' in baseSize && 'height' in baseSize) {