From ad25ff055cfb152a776bdc9ff051eab9337e1e02 Mon Sep 17 00:00:00 2001 From: Pawel Date: Tue, 12 Dec 2023 02:03:51 +0000 Subject: [PATCH] Fixed a case where ".0" is being reduced to "." --- src/minify.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/minify.ts b/src/minify.ts index 4932fee..ac3d5cd 100644 --- a/src/minify.ts +++ b/src/minify.ts @@ -681,6 +681,7 @@ export class GlslMinify { /** Token type of the immediately preceding token */ let prevType = TokenType.ttNone; + let prevPrevType = TokenType.ttNone; let match: string[]; while ((match = tokenRegex.exec(content))) { @@ -763,7 +764,7 @@ export class GlslMinify { case TokenType.ttNumeric: { // Special case for numerics: we can omit a zero following a dot (e.g. "1." is the same as "1.0") in GLSL - if (token === '0' && prevType === TokenType.ttDot) { + if (token === "0" && prevType === TokenType.ttDot && prevPrevType === TokenType.ttNumeric) { break; } @@ -897,6 +898,7 @@ export class GlslMinify { } // Advance to the next token + prevPrevType = prevType; prevType = type; }