mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-31 22:41:53 +02:00
tpl/urls: Return empty string when JoinPath has zero args
This commit is contained in:
committed by
Bjørn Erik Pedersen
parent
065ae003a5
commit
150d190ff0
@@ -187,16 +187,19 @@ func (ns *Namespace) AbsLangURL(s any) (template.HTML, error) {
|
||||
}
|
||||
|
||||
// JoinPath joins the provided elements into a URL string and cleans the result
|
||||
// of any ./ or ../ elements.
|
||||
// of any ./ or ../ elements. If the argument list is empty, JoinPath returns
|
||||
// an empty string.
|
||||
func (ns *Namespace) JoinPath(elements ...any) (string, error) {
|
||||
|
||||
if len(elements) == 0 {
|
||||
return "", nil
|
||||
}
|
||||
|
||||
var selements []string
|
||||
for _, e := range elements {
|
||||
switch v := e.(type) {
|
||||
case []string:
|
||||
for _, e := range v {
|
||||
selements = append(selements, e)
|
||||
}
|
||||
selements = append(selements, v...)
|
||||
case []any:
|
||||
for _, e := range v {
|
||||
se, err := cast.ToStringE(e)
|
||||
|
Reference in New Issue
Block a user