Skip to content

Commit afe2758

Browse files
committed
Removed the trim dep from getConditionsFromQueryParams
1 parent f32759f commit afe2758

File tree

1 file changed

+6
-11
lines changed

1 file changed

+6
-11
lines changed
Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import { trim } from "lodash";
2-
31
/**
42
* Extracts conditions as arrays from a single "param" string PostCSS provides
53
* for at-rules.
@@ -11,18 +9,15 @@ import { trim } from "lodash";
119
export default function getConditionsFromQueryParams(params) {
1210
return params.split(",").map(andParams => {
1311
return andParams.match(/\(([^\)]*)\)/g).map(condition => {
14-
let conditionArr = trim(condition, "()");
15-
16-
conditionArr = conditionArr.match(/([a-z-]*)([ :><=]*)([a-z0-9\.]*)/i);
17-
conditionArr.shift();
18-
19-
conditionArr = conditionArr.map(trim);
12+
const conditionArr = condition.match(
13+
/\(([a-z-]*) *([:><=]*) *([a-z0-9\.]*)\)/i
14+
);
2015

21-
if (["landscape", "portrait"].indexOf(conditionArr[2]) === -1) {
22-
conditionArr[2] = parseFloat(conditionArr[2]);
16+
if (["landscape", "portrait"].indexOf(conditionArr[3]) === -1) {
17+
conditionArr[3] = parseFloat(conditionArr[3]);
2318
}
2419

25-
return conditionArr;
20+
return conditionArr.slice(1);
2621
});
2722
});
2823
}

0 commit comments

Comments
 (0)