Skip to content
This repository has been archived by the owner on Jan 13, 2023. It is now read-only.

Commit

Permalink
given two strings attempts to perform case insensitive matching betwe…
Browse files Browse the repository at this point in the history
…en them
  • Loading branch information
itzmeanjan committed Jan 31, 2021
1 parent 74669bc commit b2193c3
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions app/pubsub/subscription.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package pubsub

import (
"fmt"
"log"
"regexp"
"strings"
Expand Down Expand Up @@ -156,6 +157,20 @@ func (s *SubscriptionRequest) GetTransactionFilters() []string {
return []string{matches[4], matches[6]}
}

// CheckSimilarity - Performing case insensitive matching between two
// strings
func CheckSimilarity(first string, second string) bool {

reg, err := regexp.Compile(fmt.Sprintf("(?i)^(%s)$", first))
if err != nil {
log.Printf("[!] Failed to parse regex pattern : %s\n", err.Error())
return false
}

return reg.MatchString(second)

}

// DoesMatchWithPublishedTransactionData - All `transaction` topic listeners i.e. subscribers are
// going to get notified when new transaction detected, but they will only send those data to client application
// ( connected over websocket ), to which client has subscribed to
Expand Down

0 comments on commit b2193c3

Please sign in to comment.