Skip to content

Commit

Permalink
Merge pull request #152 from maxwroc/FixTooGreedyMatching
Browse files Browse the repository at this point in the history
Fix greedy wildcard search
  • Loading branch information
maxwroc authored Oct 26, 2020
2 parents a2a57dc + 1033263 commit b8ecec1
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "battery-state-card",
"version": "1.5.1",
"version": "1.5.2",
"description": "Battery State card for Home Assistant",
"main": "dist/battery-state-card.js",
"repository": {
Expand Down
2 changes: 1 addition & 1 deletion src/battery-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const operatorHandlers: { [key in FilterOperator]: (val: string | number | undef
// create regexp after removing slashes
exp = new RegExp(pattern.substr(1, pattern.length - 2));
} else if (pattern.indexOf("*") != -1) {
exp = new RegExp(pattern.replace(/\*/g, ".*"));
exp = new RegExp("^" + pattern.replace(/\*/g, ".*") + "$");
}

return exp ? exp.test(val.toString()) : val === pattern;
Expand Down
2 changes: 1 addition & 1 deletion src/utils.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { HomeAssistant } from "./ha-types";

console.info(
"%c BATTERY-STATE-CARD %c 1.5.1",
"%c BATTERY-STATE-CARD %c 1.5.2",
"color: white; background: forestgreen; font-weight: 700;",
"color: forestgreen; background: white; font-weight: 700;",
);
Expand Down

0 comments on commit b8ecec1

Please sign in to comment.