aboutsummaryrefslogtreecommitdiff
path: root/brokenlinks/brokenlinks_test.go
diff options
context:
space:
mode:
authorShulhan <ms@kilabit.info>2026-02-11 10:47:42 +0700
committerShulhan <ms@kilabit.info>2026-02-11 21:45:06 +0700
commit8100b3be0730173a77f1a64f9ac6bc8862a159ac (patch)
tree46d0bdb4a6f3e6c5e709826d61d34259e209d3a4 /brokenlinks/brokenlinks_test.go
parente59724f4d701f8889167219b2ccc18f4e8954034 (diff)
downloadjarink-8100b3be0730173a77f1a64f9ac6bc8862a159ac.tar.xz
brokenlinks: make link that return HTML always end with slash
If parent URL like "/page" return the body as HTML page, the URL should be end with slash to make the relative links inside it works when joined with the parent URL.
Diffstat (limited to 'brokenlinks/brokenlinks_test.go')
-rw-r--r--brokenlinks/brokenlinks_test.go19
1 files changed, 10 insertions, 9 deletions
diff --git a/brokenlinks/brokenlinks_test.go b/brokenlinks/brokenlinks_test.go
index f251165..ab857cd 100644
--- a/brokenlinks/brokenlinks_test.go
+++ b/brokenlinks/brokenlinks_test.go
@@ -223,11 +223,12 @@ func TestScan(t *testing.T) {
if err != nil {
t.Fatal(err)
}
+ parsedTestUrl.Path = `/`
parsedUrlBrokenHtml, err := url.Parse(testUrl + `/broken.html`)
if err != nil {
t.Fatal(err)
}
- parsedUrlPage2, err := url.Parse(testUrl + `/page2`)
+ parsedUrlPage2, err := url.Parse(testUrl + `/page2/`)
if err != nil {
t.Fatal(err)
}
@@ -254,7 +255,7 @@ func TestScan(t *testing.T) {
opts: brokenlinks.Options{
Url: `http://127.0.0.1:14594`,
},
- expError: `Scan: Get "http://127.0.0.1:14594": dial tcp 127.0.0.1:14594: connect: connection refused`,
+ expError: `Scan: Get "http://127.0.0.1:14594/": dial tcp 127.0.0.1:14594: connect: connection refused`,
}, {
desc: `With invalid IgnoreStatus`,
opts: brokenlinks.Options{
@@ -270,14 +271,14 @@ func TestScan(t *testing.T) {
},
expError: `Scan: Options: unknown status code "50"`,
}, {
- desc: `With Url=testUrl`,
+ desc: `With Url=` + testUrl,
opts: brokenlinks.Options{
Url: testUrl,
IgnoreStatus: `403`,
Insecure: true,
},
exp: map[string][]jarink.Link{
- testUrl: []jarink.Link{
+ testUrl + `/`: []jarink.Link{
{
ParentUrl: parsedTestUrl,
Url: testUrl + `/broken.png`,
@@ -337,7 +338,7 @@ func TestScan(t *testing.T) {
Kind: int(atom.A),
},
},
- testUrl + `/page2`: []jarink.Link{
+ testUrl + `/page2/`: []jarink.Link{
{
ParentUrl: parsedUrlPage2,
Url: testUrl + `/broken.png`,
@@ -359,12 +360,12 @@ func TestScan(t *testing.T) {
}, {
// Scanning on "/page2" should not scan the the "/" or other
// pages other than below of "/page2" itself.
- desc: `With Url=/page2`,
+ desc: `With Url=` + testUrl + `/page2`,
opts: brokenlinks.Options{
Url: testUrl + `/page2`,
},
exp: map[string][]jarink.Link{
- testUrl + `/page2`: []jarink.Link{
+ testUrl + `/page2/`: []jarink.Link{
{
ParentUrl: parsedUrlPage2,
Url: testUrl + `/broken.png`,
@@ -411,7 +412,7 @@ func TestScan(t *testing.T) {
func TestScan_pastResult(t *testing.T) {
var testUrl = `http://` + testAddress
- parsedUrlPage2, err := url.Parse(testUrl + `/page2`)
+ parsedUrlPage2, err := url.Parse(testUrl + `/page2/`)
if err != nil {
t.Fatal(err)
}
@@ -438,7 +439,7 @@ func TestScan_pastResult(t *testing.T) {
IgnoreStatus: `403`,
},
exp: map[string][]jarink.Link{
- testUrl + `/page2`: []jarink.Link{
+ testUrl + `/page2/`: []jarink.Link{
{
ParentUrl: parsedUrlPage2,
Url: testUrl + `/broken.png`,