almost all ready
This commit is contained in:
@@ -129,6 +129,9 @@ func (r *CategoryRoute) Match(path string) (slug string, ok bool) {
|
||||
}
|
||||
|
||||
func (r *CategoryRoute) MatchInfo(path string) (*CategoryMatch, bool) {
|
||||
if hasExcludedStaticSegment(path) {
|
||||
return nil, false
|
||||
}
|
||||
if r == nil || r.regex == nil {
|
||||
return fallbackCategoryMatch(path)
|
||||
}
|
||||
@@ -262,6 +265,9 @@ func (r *ProductRoute) Match(path string) (slug string, ok bool) {
|
||||
}
|
||||
|
||||
func (r *ProductRoute) MatchInfo(path string) (*ProductMatch, bool) {
|
||||
if hasExcludedStaticSegment(path) {
|
||||
return nil, false
|
||||
}
|
||||
if r == nil || r.regex == nil {
|
||||
return fallbackProductMatch(path)
|
||||
}
|
||||
@@ -500,6 +506,9 @@ func fallbackProductMatch(path string) (*ProductMatch, bool) {
|
||||
if path == "" {
|
||||
return nil, false
|
||||
}
|
||||
if hasExcludedStaticSegment(path) {
|
||||
return nil, false
|
||||
}
|
||||
if hasExcludedContentSegment(path) {
|
||||
return nil, false
|
||||
}
|
||||
@@ -543,6 +552,9 @@ func fallbackCategoryMatch(path string) (*CategoryMatch, bool) {
|
||||
if path == "" {
|
||||
return nil, false
|
||||
}
|
||||
if hasExcludedStaticSegment(path) {
|
||||
return nil, false
|
||||
}
|
||||
if hasExcludedContentSegment(path) {
|
||||
return nil, false
|
||||
}
|
||||
@@ -601,3 +613,19 @@ func hasExcludedContentSegment(path string) bool {
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func hasExcludedStaticSegment(path string) bool {
|
||||
path = strings.TrimSpace(path)
|
||||
if path == "" {
|
||||
return false
|
||||
}
|
||||
path = strings.Trim(path, "/")
|
||||
if path == "" {
|
||||
return false
|
||||
}
|
||||
first := path
|
||||
if idx := strings.IndexByte(first, '/'); idx >= 0 {
|
||||
first = first[:idx]
|
||||
}
|
||||
return strings.EqualFold(strings.TrimSpace(first), "img")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user