Skip to content

Commit 4dbf807

Browse files
committed
Fixed warning placement and removed parts of parseColor function
value being passed to the function was already converted to hex so no need to check other types
1 parent 4bd3fb1 commit 4dbf807

File tree

1 file changed

+1
-11
lines changed

1 file changed

+1
-11
lines changed

server/out/helpers/color-contrast.js

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -32,16 +32,6 @@ function parseColor(color) {
3232
if (hexMatch) {
3333
return hexMatch.slice(1).map((c) => parseInt(c, 16));
3434
}
35-
const rgbMatch = color.match(/^rgb\((\d+),\s*(\d+),\s*(\d+)\)$/);
36-
if (rgbMatch) {
37-
return rgbMatch.slice(1).map((c) => parseInt(c, 10));
38-
}
39-
const rgbaMatch = color.match(
40-
/^rgba\((\d+),\s*(\d+),\s*(\d+),\s*([0-9]*[.])?[0-9]+\)$/
41-
);
42-
if (rgbaMatch) {
43-
return rgbaMatch.slice(1, 4).map((c) => parseInt(c, 10));
44-
}
4535
throw new Error("Invalid color format: " + color);
4636
}
4737

@@ -202,7 +192,7 @@ function checkContrast(element, window, document, html, index) {
202192
// const elementStartIndex = index + (element.outerHTML).lastIndexOf(">" + element.textContent) + 1;
203193
// const elementEndIndex = elementStartIndex + element.textContent.length;
204194
const elementStartIndex = index + 1;
205-
const elementEndIndex = elementStartIndex + (element.outerHTML).indexOf(">");
195+
const elementEndIndex = elementStartIndex + (element.outerHTML).indexOf(">") - 1;
206196

207197
// Only return the element if it has a color contrast issue
208198
if (elementStartIndex < 1 || elementEndIndex < 1) {

0 commit comments

Comments
 (0)