mirror of
https://github.com/yusing/godoxy.git
synced 2025-05-20 04:42:33 +02:00
fix: icon not exists error on loading icon cache
This commit is contained in:
parent
770c698332
commit
28d9a72908
1 changed files with 8 additions and 4 deletions
|
@ -77,6 +77,10 @@ func (u *IconURL) HasIcon() bool {
|
||||||
|
|
||||||
// Parse implements strutils.Parser.
|
// Parse implements strutils.Parser.
|
||||||
func (u *IconURL) Parse(v string) error {
|
func (u *IconURL) Parse(v string) error {
|
||||||
|
return u.parse(v, true)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (u *IconURL) parse(v string, checkExists bool) error {
|
||||||
if v == "" {
|
if v == "" {
|
||||||
return ErrInvalidIconURL
|
return ErrInvalidIconURL
|
||||||
}
|
}
|
||||||
|
@ -130,11 +134,11 @@ func (u *IconURL) Parse(v string) error {
|
||||||
IsLight: isLight,
|
IsLight: isLight,
|
||||||
IsDark: isDark,
|
IsDark: isDark,
|
||||||
}
|
}
|
||||||
if !u.HasIcon() {
|
if checkExists && !u.HasIcon() {
|
||||||
return ErrInvalidIconURL.Withf("no such icon %s from %s", reference, u.IconSource)
|
return ErrInvalidIconURL.Withf("no such icon %s.%s from %s", reference, format, u.IconSource)
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
return ErrInvalidIconURL.Withf("%s", v)
|
return ErrInvalidIconURL.Subject(v)
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
@ -184,5 +188,5 @@ func (u *IconURL) MarshalText() ([]byte, error) {
|
||||||
|
|
||||||
// UnmarshalText implements encoding.TextUnmarshaler.
|
// UnmarshalText implements encoding.TextUnmarshaler.
|
||||||
func (u *IconURL) UnmarshalText(data []byte) error {
|
func (u *IconURL) UnmarshalText(data []byte) error {
|
||||||
return u.Parse(string(data))
|
return u.parse(string(data), false)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue