From 1643fef377aab70bbe769ebc69fb46337d3446d9 Mon Sep 17 00:00:00 2001 From: Ryan Cavicchioni Date: Sun, 7 Aug 2022 07:12:53 -0500 Subject: [PATCH] Add HasCommand() --- command/util.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/command/util.go b/command/util.go index 57ac981..8b4a1f7 100644 --- a/command/util.go +++ b/command/util.go @@ -45,3 +45,19 @@ func BuildURI(rawuri, rawpath string) string { u.Path = path.Join(u.Path, rawpath) return u.String() } + +func HasCommand(s, prefix, cmd string) bool { + if len(s) < 2 { + return false + } + + if string(s[0]) != prefix { + return false + } + + if s[1:] == cmd { + return true + } + + return false +}