Skip to content

Commit 50c0c15

Browse files
committed
Fixed IQ Puzzles statuses resetting on update
If `match` is called with a global RegExp, capturing groups are not included in the return value: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/match#return_value. As such: > If you want to obtain capture groups and the global flag is set, you > need to use `RegExp.prototype.exec()` or `String.prototype.matchAll()` > instead. https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/match#description So, since we need only one image, we can safely use `matchAll`, and then only look at the first element. (introduced by 53ba184)
1 parent 53ba184 commit 50c0c15

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/recipes/iq_puzzles/IQPuzzlesRecipe.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,9 @@ export class IQPuzzlesRecipe implements Recipe {
105105
const name = array[0];
106106

107107
const image = array[1];
108-
const imageLinkMatch = image.match(imageLinkRegex);
109-
if (imageLinkMatch == null || imageLinkMatch.groups == null) {
108+
const imageLinkMatches = Array.from(image.matchAll(imageLinkRegex));
109+
const imageLinkMatch = imageLinkMatches[0];
110+
if (imageLinkMatch == undefined || imageLinkMatch == null || imageLinkMatch.groups == null) {
110111
return [];
111112
}
112113
const imageLink = imageLinkMatch.groups.link;

0 commit comments

Comments
 (0)