Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed a case where ".0" is being reduced to "." #73

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/minify.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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))) {
Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -897,6 +898,7 @@ export class GlslMinify {
}

// Advance to the next token
prevPrevType = prevType;
prevType = type;
}

Expand Down