summaryrefslogtreecommitdiff
path: root/lib/SlackBuilder/LatestVersionCheck.hs
diff options
context:
space:
mode:
authorEugen Wissner <belka@caraus.de>2024-09-09 16:47:44 +0200
committerEugen Wissner <belka@caraus.de>2024-09-09 16:47:44 +0200
commit6ead225e882be4b4b3c9bc09b079feca4abd5f61 (patch)
tree4dc128ce08784ee445fe10a4ce8cdd3fd5803314 /lib/SlackBuilder/LatestVersionCheck.hs
parent1418e0ae46d3805c20796b0ff7896881658798df (diff)
downloadslackbuilder-6ead225e882be4b4b3c9bc09b079feca4abd5f61.tar.gz
Add nginx
Diffstat (limited to 'lib/SlackBuilder/LatestVersionCheck.hs')
-rw-r--r--lib/SlackBuilder/LatestVersionCheck.hs15
1 files changed, 11 insertions, 4 deletions
diff --git a/lib/SlackBuilder/LatestVersionCheck.hs b/lib/SlackBuilder/LatestVersionCheck.hs
index a1e8abc..d6410dc 100644
--- a/lib/SlackBuilder/LatestVersionCheck.hs
+++ b/lib/SlackBuilder/LatestVersionCheck.hs
@@ -54,9 +54,9 @@ data PackageOwner = PackageOwner
} deriving (Eq, Show)
data MatchState = MatchState
- { ignoring :: Bool
- , matched :: Text
- , pattern' :: [MatchToken]
+ { ignoring :: !Bool
+ , matched :: !Text
+ , pattern' :: ![MatchToken]
} deriving (Eq, Show)
data MatchToken
@@ -68,7 +68,7 @@ data MatchToken
deriving (Eq, Show)
-- | Matches a string (for example a version name or CVS tag) against a pattern.
--- Returns the matched part of the string or 'Nothing' if there is no match.
+-- Returns the matched part of the string or 'Nothing' if there is not match.
--
-- The pattern is just a list of characters with some special characters and
-- sequences.
@@ -79,6 +79,8 @@ data MatchToken
-- * \\. - Matches zero or more digits or dots.
-- * \\\\ - Matches a back slash.
-- * * - Matches everything.
+-- * [ ] - Match one of the characters inbetween. The characters are
+-- matched verbatim.
--
-- For example the following expression matches tags like @v1.2.3@, but returns
-- only @1.2.3@.
@@ -112,6 +114,11 @@ match fullPattern input =
Just ('\\', remaining') -> SymbolMatchToken '\\'
: parsePattern remaining'
Just (_, remaining') -> parsePattern remaining'
+ | Just (firstChar, remaining) <- Text.uncons input'
+ , firstChar == '['
+ , Just lastBracket <- Text.findIndex (== ']') remaining
+ = OneOfMatchToken (Text.unpack $ Text.take lastBracket remaining)
+ : parsePattern (Text.drop (succ lastBracket) remaining)
| Just (firstChar, remaining) <- Text.uncons input' =
let token =
case firstChar of