@@ -36,53 +36,41 @@ func TestUnescapeURL(t *testing.T) {
36
36
}
37
37
38
38
func TestValidateDownloadURL (t * testing.T ) {
39
- type Args struct {
40
- url string
41
- allowHost string
42
- }
43
39
tests := []struct {
44
40
name string
45
- args Args
41
+ url string
46
42
noErr bool
47
43
}{
48
44
{
49
- name : "validate feishu url success" ,
50
- args : Args {
51
- url : "https://sample.feishu.cn/docx/doccnByZP6puODElAYySJkPIfUb" ,
52
- allowHost : "" ,
53
- },
45
+ name : "validate feishu url success" ,
46
+ url : "https://sample.feishu.cn/docx/doccnByZP6puODElAYySJkPIfUb" ,
47
+ noErr : true ,
48
+ },
49
+ {
50
+ name : "validate larksuite url success" ,
51
+ url : "https://sample.larksuite.com/wiki/doccnByZP6puODElAYySJkPIfUb" ,
54
52
noErr : true ,
55
53
},
56
54
{
57
- name : "validate larksuite url success" ,
58
- args : Args {
59
- url : "https://sample.larksuite.com/wiki/doccnByZP6puODElAYySJkPIfUb" ,
60
- allowHost : "" ,
61
- },
55
+ name : "validate larksuite url success" ,
56
+ url : "https://sample.sg.larksuite.com/wiki/doccnByZP6puODElAYySJkPIfUb" ,
62
57
noErr : true ,
63
58
},
64
59
{
65
- name : "validate feishu url success with allow host" ,
66
- args : Args {
67
- url : "https://f.mioffice.cn/docx/doccnByZP6puODElAYySJkPIfUb" ,
68
- allowHost : "f.mioffice.cn" ,
69
- },
60
+ name : "validate feishu url success" ,
61
+ url : "https://sample.f.mioffice.cn/docx/doccnByZP6puODElAYySJkPIfUb" ,
70
62
noErr : true ,
71
63
},
72
64
{
73
- name : "validate arbitrary url failed" ,
74
- args : Args {
75
- url : "https://google.com" ,
76
- allowHost : "" ,
77
- },
65
+ name : "validate arbitrary url failed" ,
66
+ url : "https://google.com" ,
78
67
noErr : false ,
79
68
},
80
69
}
81
70
for _ , tt := range tests {
82
71
t .Run (tt .name , func (t * testing.T ) {
83
- url , allowHost := tt .args .url , tt .args .allowHost
84
- if _ , _ , _ , got := ValidateDownloadURL (url , allowHost ); (got == nil ) != tt .noErr {
85
- t .Errorf ("ValidateDownloadURL(%v, %v)" , url , allowHost )
72
+ if _ , _ , got := ValidateDownloadURL (tt .url ); (got == nil ) != tt .noErr {
73
+ t .Errorf ("ValidateDownloadURL(%v)" , tt .url )
86
74
}
87
75
})
88
76
}
0 commit comments