diff options
author | Valery Piashchynski <[email protected]> | 2021-06-16 14:04:11 +0300 |
---|---|---|
committer | Valery Piashchynski <[email protected]> | 2021-06-16 14:04:11 +0300 |
commit | 8483f605037317e9ac266f893d8ef80ff3a6a56e (patch) | |
tree | 98b5c6f5a6fd47b39306b5f30bbaa772b7f59893 /plugins/websockets/wildcard.go | |
parent | 9dc98d43b0c0de3e1e1bd8fdc97c122c7c7c594f (diff) |
- Add origin check for the websockets
Signed-off-by: Valery Piashchynski <[email protected]>
Diffstat (limited to 'plugins/websockets/wildcard.go')
-rw-r--r-- | plugins/websockets/wildcard.go | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/plugins/websockets/wildcard.go b/plugins/websockets/wildcard.go new file mode 100644 index 00000000..2f1c6601 --- /dev/null +++ b/plugins/websockets/wildcard.go @@ -0,0 +1,12 @@ +package websockets + +import "strings" + +type wildcard struct { + prefix string + suffix string +} + +func (w wildcard) match(s string) bool { + return len(s) >= len(w.prefix)+len(w.suffix) && strings.HasPrefix(s, w.prefix) && strings.HasSuffix(s, w.suffix) +} |