Skip to content

Commit ce8f680

Browse files
committed
other: simplify regex
1 parent 5bd117c commit ce8f680

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

formatter/formatter_html_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ func TestHTMLFormatter_Format(t *testing.T) {
137137
wantErr: false,
138138
validate: func(f *HTMLFormatter, output string, t *testing.T) {
139139
expect := 2
140-
re := regexp.MustCompile(`<li><a href="\#192\.168\.1\.(1|2)">`)
140+
re := regexp.MustCompile(`<li><a href="#192\.168\.1\.([12])">`)
141141
actual := len(re.FindAllString(output, -1))
142142
if expect != actual {
143143
t.Fatalf("Expected %d addresses in TOC, got %d", expect, actual)
@@ -199,7 +199,7 @@ func TestHTMLFormatter_Format(t *testing.T) {
199199
wantErr: false,
200200
validate: func(f *HTMLFormatter, output string, t *testing.T) {
201201
expect := 1
202-
re := regexp.MustCompile(`<li><a href="\#192\.168\.1\.(1|2)">`)
202+
re := regexp.MustCompile(`<li><a href="#192\.168\.1\.([12])">`)
203203
actual := len(re.FindAllString(output, -1))
204204
if expect != actual {
205205
t.Fatalf("Expected %d addresses in TOC, got %d", expect, actual)
@@ -261,7 +261,7 @@ func TestHTMLFormatter_Format(t *testing.T) {
261261
wantErr: false,
262262
validate: func(f *HTMLFormatter, output string, t *testing.T) {
263263
expect := 2
264-
re := regexp.MustCompile(`<li><a href="\#192\.168\.1\.(1|2)">`)
264+
re := regexp.MustCompile(`<li><a href="#192\.168\.1\.([12])">`)
265265
actual := len(re.FindAllString(output, -1))
266266
if expect != actual {
267267
t.Fatalf("Expected %d addresses in TOC, got %d", expect, actual)

formatter/formatter_md_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ func TestMarkdownFormatter_Format(t *testing.T) {
223223
wantErr: false,
224224
validate: func(f *MarkdownFormatter, output string, t *testing.T) {
225225
expect := 2
226-
re := regexp.MustCompile(`## 192\.168\.1\.[0-9]+`)
226+
re := regexp.MustCompile(`## 192\.168\.1\.\d+`)
227227
actual := len(re.FindAllString(output, -1))
228228
if expect != actual {
229229
t.Fatalf("Expected %d host headers, got %d", expect, actual)
@@ -304,7 +304,7 @@ func TestMarkdownFormatter_Format(t *testing.T) {
304304
wantErr: false,
305305
validate: func(f *MarkdownFormatter, output string, t *testing.T) {
306306
expect := 3
307-
re := regexp.MustCompile(`## 192\.168\.1\.[0-9]+`)
307+
re := regexp.MustCompile(`## 192\.168\.1\.\d+`)
308308
actual := len(re.FindAllString(output, -1))
309309
if expect != actual {
310310
t.Fatalf("Expected %d host headers, got %d", expect, actual)

0 commit comments

Comments
 (0)