Update author & library item image endpoints to clamp width/height query params

This commit is contained in:
advplyr 2026-04-17 16:30:08 -05:00
parent 88667d00a1
commit 455e605162
3 changed files with 16 additions and 6 deletions

View file

@ -54,6 +54,16 @@ module.exports.isNullOrNaN = (num) => {
return num === null || isNaN(num)
}
/**
* @param {number|null|undefined} value
* @param {number} max
* @returns {number|null}
*/
module.exports.clampPositiveInt = (value, max) => {
if (value == null || !Number.isFinite(value) || value <= 0) return null
return Math.min(Math.floor(value), max)
}
const xmlToJSON = (xml) => {
return new Promise((resolve, reject) => {
parseString(xml, (err, results) => {