diff --git a/index.js b/index.js index 66e0a3c..abbd74f 100644 --- a/index.js +++ b/index.js @@ -35,8 +35,8 @@ app.get(["/@:name", "/get/@:name"], }), query: z.object({ theme: z.string().default("moebooru"), - num: z.coerce.number().min(0).max(1000000000000000).default(0), // a carry-safe integer, less than `2^53-1`, and aesthetically pleasing in decimal. - padding: z.coerce.number().min(0).max(16).default(7), + num: z.coerce.number().int().min(0).max(1e15).default(0), // a carry-safe integer, less than `2^53-1`, and aesthetically pleasing in decimal. + padding: z.coerce.number().int().min(0).max(16).default(7), offset: z.coerce.number().min(-500).max(500).default(0), align: z.enum(["top", "center", "bottom"]).default("top"), scale: z.coerce.number().min(0.1).max(2).default(1), @@ -54,7 +54,7 @@ app.get(["/@:name", "/get/@:name"], "cache-control": "max-age=0, no-cache, no-store, must-revalidate", }); - const data = await getCountByName(name, num); + const data = await getCountByName(String(name), Number(num)); if (name === "demo") { res.set("cache-control", "max-age=31536000"); diff --git a/utils/themify.js b/utils/themify.js index 7aa6583..9a2cd66 100644 --- a/utils/themify.js +++ b/utils/themify.js @@ -45,8 +45,9 @@ function getCountImage(params) { let { count, theme = 'moebooru', padding = 7, offset = 0, align = 'top', scale = 1, pixelated = '1', darkmode = 'auto' } = params if (!(theme in themeList)) theme = 'moebooru' - padding = parseInt(padding, 10) - offset = parseInt(offset, 10) + padding = parseInt(Number(padding), 10) + offset = parseFloat(Number(offset), 10) + scale = parseFloat(Number(scale), 10) // This is not the greatest way for generating an SVG but it'll do for now const countArray = count.toString().padStart(padding, '0').split('') diff --git a/views/index.pug b/views/index.pug index 313eb3e..4848c74 100644 --- a/views/index.pug +++ b/views/index.pug @@ -135,7 +135,7 @@ html td: code num td Set counter display number, 0 for disable, default is code 0 - td: input#num(type='number', value='0', min='0', max='1000000000000000', step='1', oninput='this.value = this.value.replace(/[^0-9]/g, "")') + td: input#num(type='number', value='0', min='0', max='1e15', step='1', oninput='this.value = this.value.replace(/[^0-9]/g, "")') button#get(onclick='_evt_push("click", "normal", "get_counter")') Generate