mirror of
https://github.com/stashapp/stash.git
synced 2025-12-17 04:14:39 +03:00
Performer urls (#4958)
* Populate URLs from legacy fields * Return nil properly in xpath/json scrapers * Improve migration logging
This commit is contained in:
47
pkg/utils/url_test.go
Normal file
47
pkg/utils/url_test.go
Normal file
@@ -0,0 +1,47 @@
|
||||
package utils
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestURLFromHandle(t *testing.T) {
|
||||
type args struct {
|
||||
input string
|
||||
siteURL string
|
||||
}
|
||||
tests := []struct {
|
||||
name string
|
||||
args args
|
||||
want string
|
||||
}{
|
||||
{
|
||||
name: "input is already a URL https",
|
||||
args: args{
|
||||
input: "https://foo.com",
|
||||
siteURL: "https://bar.com",
|
||||
},
|
||||
want: "https://foo.com",
|
||||
},
|
||||
{
|
||||
name: "input is already a URL http",
|
||||
args: args{
|
||||
input: "http://foo.com",
|
||||
siteURL: "https://bar.com",
|
||||
},
|
||||
want: "http://foo.com",
|
||||
},
|
||||
{
|
||||
name: "input is not a URL",
|
||||
args: args{
|
||||
input: "foo",
|
||||
siteURL: "https://foo.com",
|
||||
},
|
||||
want: "https://foo.com/foo",
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
if got := URLFromHandle(tt.args.input, tt.args.siteURL); got != tt.want {
|
||||
t.Errorf("URLFromHandle() = %v, want %v", got, tt.want)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user