Skip to content

Commit 62b4042

Browse files
committed
chore(regex): port regex fixes from 4.1.3
1 parent a09f484 commit 62b4042

File tree

6 files changed

+778
-575
lines changed

6 files changed

+778
-575
lines changed

.husky/_/husky.sh

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#!/bin/sh
2+
if [ -z "$husky_skip_init" ]; then
3+
debug () {
4+
[ "$HUSKY_DEBUG" = "1" ] && echo "husky (debug) - $1"
5+
}
6+
7+
readonly hook_name="$(basename "$0")"
8+
debug "starting $hook_name..."
9+
10+
if [ "$HUSKY" = "0" ]; then
11+
debug "HUSKY env variable is set to 0, skipping hook"
12+
exit 0
13+
fi
14+
15+
if [ -f ~/.huskyrc ]; then
16+
debug "sourcing ~/.huskyrc"
17+
. ~/.huskyrc
18+
fi
19+
20+
export readonly husky_skip_init=1
21+
sh -e "$0" "$@"
22+
exitCode="$?"
23+
24+
if [ $exitCode != 0 ]; then
25+
echo "husky - $hook_name hook exited with code $exitCode (error)"
26+
exit $exitCode
27+
fi
28+
29+
exit 0
30+
fi

docs/assets/polished.js

Lines changed: 8 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1060,7 +1060,7 @@
10601060
};
10611061
}
10621062

1063-
function _createForOfIteratorHelperLoose(o, allowArrayLike) { var it; if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; return function () { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } it = o[Symbol.iterator](); return it.next.bind(it); }
1063+
function _createForOfIteratorHelperLoose(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (it) return (it = it.call(o)).next.bind(it); if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; return function () { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
10641064

10651065
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
10661066

@@ -1168,7 +1168,7 @@
11681168
}
11691169

11701170
function isDataURI(fontFilePath) {
1171-
return !!fontFilePath.match(dataURIRegex);
1171+
return !!fontFilePath.replace(/\s+/g, ' ').match(dataURIRegex);
11721172
}
11731173

11741174
function generateFileReferences(fontFilePath, fileFormats, formatHint) {
@@ -1418,15 +1418,7 @@
14181418
return template.trim();
14191419
}
14201420

1421-
function _templateObject() {
1422-
var data = _taggedTemplateLiteralLoose__default['default'](["linear-gradient(", "", ")"]);
1423-
1424-
_templateObject = function _templateObject() {
1425-
return data;
1426-
};
1427-
1428-
return data;
1429-
}
1421+
var _templateObject;
14301422

14311423
/**
14321424
* CSS for declaring a linear gradient, including a fallback background-color. The fallback is either the first color-stop or an explicitly passed fallback color.
@@ -1469,7 +1461,7 @@
14691461

14701462
return {
14711463
backgroundColor: fallback || colorStops[0].replace(/,\s+/g, ',').split(' ')[0].replace(/,(?=\S)/g, ', '),
1472-
backgroundImage: constructGradientValue(_templateObject(), toDirection, colorStops.join(', ').replace(/,(?=\S)/g, ', '))
1464+
backgroundImage: constructGradientValue(_templateObject || (_templateObject = _taggedTemplateLiteralLoose__default['default'](["linear-gradient(", "", ")"])), toDirection, colorStops.join(', ').replace(/,(?=\S)/g, ', '))
14731465
};
14741466
}
14751467

@@ -1601,15 +1593,7 @@
16011593
}];
16021594
}
16031595

1604-
function _templateObject$1() {
1605-
var data = _taggedTemplateLiteralLoose__default['default'](["radial-gradient(", "", "", "", ")"]);
1606-
1607-
_templateObject$1 = function _templateObject() {
1608-
return data;
1609-
};
1610-
1611-
return data;
1612-
}
1596+
var _templateObject$1;
16131597

16141598
/**
16151599
* CSS for declaring a radial gradient, including a fallback background-color. The fallback is either the first color-stop or an explicitly passed fallback color.
@@ -1658,7 +1642,7 @@
16581642

16591643
return {
16601644
backgroundColor: fallback || colorStops[0].split(' ')[0],
1661-
backgroundImage: constructGradientValue(_templateObject$1(), position, shape, extent, colorStops.join(', '))
1645+
backgroundImage: constructGradientValue(_templateObject$1 || (_templateObject$1 = _taggedTemplateLiteralLoose__default['default'](["radial-gradient(", "", "", "", ")"])), position, shape, extent, colorStops.join(', '))
16621646
};
16631647
}
16641648

@@ -2214,7 +2198,7 @@
22142198
};
22152199
}
22162200

2217-
var rgbaMatched = rgbaRegex.exec(normalizedColor);
2201+
var rgbaMatched = rgbaRegex.exec(normalizedColor.substring(0, 50));
22182202

22192203
if (rgbaMatched) {
22202204
return {
@@ -2245,7 +2229,7 @@
22452229
};
22462230
}
22472231

2248-
var hslaMatched = hslaRegex.exec(normalizedColor);
2232+
var hslaMatched = hslaRegex.exec(normalizedColor.substring(0, 50));
22492233

22502234
if (hslaMatched) {
22512235
var _hue = parseInt("" + hslaMatched[1], 10);

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "polished",
3-
"version": "3.7.1",
3+
"version": "3.7.2",
44
"description": "A lightweight toolset for writing styles in Javascript.",
55
"license": "MIT",
66
"author": "Brian Hough <hello@brianhough.net> (https://polished.js.org)",

src/color/parseToRgb.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ export default function parseToRgb(color: string): RgbColor | RgbaColor {
3939
}
4040
if (normalizedColor.match(hexRgbaRegex)) {
4141
const alpha = parseFloat(
42-
(parseInt(`${normalizedColor[7]}${normalizedColor[8]}`, 16) / 255).toFixed(2),
42+
(parseInt(`${normalizedColor[7]}${normalizedColor[8]}`, 16) / 255).toFixed(2)
4343
)
4444
return {
4545
red: parseInt(`${normalizedColor[1]}${normalizedColor[2]}`, 16),
@@ -57,7 +57,7 @@ export default function parseToRgb(color: string): RgbColor | RgbaColor {
5757
}
5858
if (normalizedColor.match(reducedRgbaHexRegex)) {
5959
const alpha = parseFloat(
60-
(parseInt(`${normalizedColor[4]}${normalizedColor[4]}`, 16) / 255).toFixed(2),
60+
(parseInt(`${normalizedColor[4]}${normalizedColor[4]}`, 16) / 255).toFixed(2)
6161
)
6262
return {
6363
red: parseInt(`${normalizedColor[1]}${normalizedColor[1]}`, 16),
@@ -74,7 +74,7 @@ export default function parseToRgb(color: string): RgbColor | RgbaColor {
7474
blue: parseInt(`${rgbMatched[3]}`, 10),
7575
}
7676
}
77-
const rgbaMatched = rgbaRegex.exec(normalizedColor)
77+
const rgbaMatched = rgbaRegex.exec(normalizedColor.substring(0, 50))
7878
if (rgbaMatched) {
7979
return {
8080
red: parseInt(`${rgbaMatched[1]}`, 10),
@@ -99,7 +99,7 @@ export default function parseToRgb(color: string): RgbColor | RgbaColor {
9999
blue: parseInt(`${hslRgbMatched[3]}`, 10),
100100
}
101101
}
102-
const hslaMatched = hslaRegex.exec(normalizedColor)
102+
const hslaMatched = hslaRegex.exec(normalizedColor.substring(0, 50))
103103
if (hslaMatched) {
104104
const hue = parseInt(`${hslaMatched[1]}`, 10)
105105
const saturation = parseInt(`${hslaMatched[2]}`, 10) / 100

src/mixins/fontFace.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,20 +22,20 @@ function generateFormatHint(format: string, formatHint: boolean): string {
2222
}
2323

2424
function isDataURI(fontFilePath: string): boolean {
25-
return !!fontFilePath.match(dataURIRegex)
25+
return !!fontFilePath.replace(/\s+/g, ' ').match(dataURIRegex)
2626
}
2727

2828
function generateFileReferences(
2929
fontFilePath: string,
3030
fileFormats: Array<string>,
31-
formatHint: boolean,
31+
formatHint: boolean
3232
): string {
3333
if (isDataURI(fontFilePath)) {
3434
return `url("${fontFilePath}")${generateFormatHint(fileFormats[0], formatHint)}`
3535
}
3636

3737
const fileFontReferences = fileFormats.map(
38-
format => `url("${fontFilePath}.${format}")${generateFormatHint(format, formatHint)}`,
38+
format => `url("${fontFilePath}.${format}")${generateFormatHint(format, formatHint)}`
3939
)
4040
return fileFontReferences.join(', ')
4141
}
@@ -49,7 +49,7 @@ function generateSources(
4949
fontFilePath?: string,
5050
localFonts?: Array<string>,
5151
fileFormats: Array<string>,
52-
formatHint: boolean,
52+
formatHint: boolean
5353
): string {
5454
const fontReferences = []
5555
if (localFonts) fontReferences.push(generateLocalReferences(localFonts))

0 commit comments

Comments
 (0)