Update serve_style.js

Co-Authored-By: Andrew Calcutt <acalcutt@techidiots.net>
This commit is contained in:
acalcutt 2024-12-29 03:19:21 -05:00
parent b6382085b7
commit d635d3ca32

View file

@ -18,9 +18,9 @@ const allowedSpriteFormats = allowedOptions(['png', 'json']);
* @returns {string} formated string for the scale or empty string if scale is invalid * @returns {string} formated string for the scale or empty string if scale is invalid
*/ */
function allowedSpriteScales(scale) { function allowedSpriteScales(scale) {
if (!scale) return ''; // Default to 1 if no scale provided if (!scale) return '';
const match = scale.match(/(\d+)x/); // Match one or more digits before 'x' const match = scale.match(/(\d+)x/);
const parsedScale = match ? parseInt(match[1], 10) : 1; // Parse the number, or default to 1 if no match const parsedScale = match ? parseInt(match[1], 10) : 1;
return '@' + Math.min(parsedScale, 3) + 'x'; return '@' + Math.min(parsedScale, 3) + 'x';
} }