Simplify getting the active path
This commit is contained in:
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user