Skip to content

Commit 5bbfca4

Browse files
committed
Refactor: Extracted regex creation logic to a new class
1 parent 39de5d1 commit 5bbfca4

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

src/recipes/hanayama_huzzles/HanayamaHuzzlesRecipe.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { MarkdownTableConverter } from 'src/markdown/MarkdownTableConverter';
22
import { MarkdownTableFactory } from 'src/markdown/MarkdownTableFactory';
3+
import { RegexFactory } from 'src/regex/RegexFactory';
34
import { WebsiteScraper } from 'src/scraping/WebsiteScraper';
45
import { TrackablesUpdater } from 'src/tracking/TrackablesUpdater';
56
import { Recipe } from '../Recipe';
@@ -98,7 +99,7 @@ export class HanayamaHuzzlesRecipe implements Recipe {
9899

99100
#markdownTableStringToHuzzles(markdownTableString: string): HanayamaHuzzle[] {
100101
const arrayOfArrays = this.markdownTableConverter.arrayOfArraysFromString(markdownTableString);
101-
const imageLinkRegex = new RegExp(/!\[[^\]]+\]\((?<link>[^)]+)(?=\))/g); // https://regex101.com/r/YlCOgc/2
102+
const imageLinkRegex = new RegexFactory().imageMarkdownLinkRegex();
102103

103104
return arrayOfArrays.flatMap(array => {
104105
if (array.length < 5) {

src/regex/RegexFactory.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
export class RegexFactory {
2+
imageMarkdownLinkRegex(): RegExp {
3+
return new RegExp(/!\[[^\]]+\]\((?<link>[^)]+)(?=\))/g); // https://regex101.com/r/YlCOgc/2
4+
}
5+
}

0 commit comments

Comments
 (0)