1
0
mirror of https://github.com/TeamNewPipe/NewPipe synced 2024-11-16 23:17:35 +01:00

Merge pull request #10377 from TeamNewPipe/image-minimizer

Image minizier: replace Number.toFixed(0) with Math.floor()
This commit is contained in:
Tobi 2023-08-25 00:54:55 +02:00 committed by GitHub
commit 25cf917969
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -86,7 +86,7 @@ module.exports = async ({github, context}) => {
});
}
// Asnyc replace function from https://stackoverflow.com/a/48032528
// Async replace function from https://stackoverflow.com/a/48032528
async function replaceAsync(str, regex, asyncFn) {
const promises = [];
str.replace(regex, (match, ...args) => {
@ -138,7 +138,7 @@ module.exports = async ({github, context}) => {
if (shouldModify) {
wasMatchModified = true;
console.log(`Modifying match '${match}'`);
return `<img alt="${g1}" src="${g2}" width=${Math.min(600, (IMG_MAX_HEIGHT_PX * probeAspectRatio).toFixed(0))} />`;
return `<img alt="${g1}" src="${g2}" width=${Math.min(600, Math.floor(IMG_MAX_HEIGHT_PX * probeAspectRatio))} />`;
}
console.log(`Match '${match}' is ok/will not be modified`);