Skip to content

Commit 7a66910

Browse files
authored
fix: don't trim white space inside quotes during minification (#28)
1 parent 9a43c8a commit 7a66910

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/parser.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { queries as supportedQueries } from './constants';
77
// It works when running parcel in dev mode, but not in build mode. Seems to
88
// have something to do with a core-js Map polyfill being used?
99
// It's now loaded from unpkg.com via ./index.html
10-
// import {getQueriesForElement, queries, logDOM} from "@testing-library/dom";
10+
//import { getQueriesForElement, queries, logDOM } from '@testing-library/dom';
1111
const {
1212
getQueriesForElement,
1313
queries,
@@ -53,8 +53,8 @@ function getLastExpression(code) {
5353
const minified = (code || '')
5454
// remove comments
5555
.replace(/\/\*[\s\S]*?\*\/|\/\/.*/g, '')
56-
// remove all white space
57-
.replace(/\s/g, '');
56+
// remove all white space outside quotes
57+
.replace(/[ ]+(?=[^"'`]*(?:["'`][^"'`]*["'`][^"'`]*)*$)/g, '');
5858

5959
const start = supportedQueries.reduce(
6060
(idx, qry) => Math.max(idx, minified.lastIndexOf(qry.method)),

0 commit comments

Comments
 (0)