Skip to content

Commit 78fb190

Browse files
demokritosSammysHP
authored andcommitted
Fix: RegEx incorrectly matches in some cases
With `/(#[a-zA-Z-]+)(-white|-black)?/`, `$1` matches the whole name of an anchor. For example, `$1` matches '#normal-icon-white' for string '#normal-icon-white'. The intention is to match '#normal-icon'.
1 parent 4256cf2 commit 78fb190

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

common/content/statusline.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ const StatusLine = Module("statusline", {
264264
let bbBackgroundLuminance = 0.2126*bbBackgroundColor[0] + 0.7152*bbBackgroundColor[1] + 0.0722*bbBackgroundColor[2];
265265
// Arbitrary threshold to switch to white-on-black icon
266266
let iconcolor = bbBackgroundLuminance < 128 ? "white" : "black";
267-
node.style.listStyleImage = node.style.listStyleImage.replace(/(#[a-zA-Z-]+)(-white|-black)?/, "$1-" + iconcolor);
267+
node.style.listStyleImage = node.style.listStyleImage.replace(/(#[\w-]+)(-white|-black)|(#[\w-]+)/, "$1$3-" + iconcolor);
268268

269269
node.style.visibility = "visible";
270270

0 commit comments

Comments
 (0)