From 739a38eb4c4482f7301f0de1af6b0e6cacd03f19 Mon Sep 17 00:00:00 2001 From: Maxim Lebedev Date: Sat, 9 Dec 2023 12:42:45 +0600 Subject: [PATCH] :label: Added IsMatch method for redirect domain --- internal/domain/redirect.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/internal/domain/redirect.go b/internal/domain/redirect.go index 8d76404..d24e562 100644 --- a/internal/domain/redirect.go +++ b/internal/domain/redirect.go @@ -1,8 +1,19 @@ package domain +import "path" + type Redirect struct { From string To string Status int Force bool } + +func (r Redirect) IsMatch(p string) bool { + matched, err := path.Match(r.From, p) + if err != nil { + return false + } + + return matched +}