Simplify getting the active path

This commit is contained in:
Achim Rohn
2025-08-22 18:37:13 +02:00
parent 7096a256a0
commit 3cc469c4a3
+2 -7
View File
@@ -1,7 +1,5 @@
package ersteller_lib
import "strings"
type Language string
const (
@@ -95,9 +93,6 @@ func (a ActivePath) GetPath(language Language) string {
}
func (a ActivePath) IsActive(c HtmxContext) bool {
pathWithLang := a.GetPath(c.GetLanguage())
if pathWithLang == c.GetLanguage().GetPath()+"/" {
return pathWithLang == c.GetPath()
}
return strings.HasPrefix(c.GetPath(), pathWithLang)
contextActivePath := c.GetActivePath()
return contextActivePath != nil && contextActivePath.From(c) == a.From(c)
}