Skip to content

Commit

Permalink
DataBundle: Improved version strip from filename
Browse files Browse the repository at this point in the history
The regular expression was having trouble with detecting version suffixes in some cases.
  • Loading branch information
skyjake committed Dec 31, 2020
1 parent bb5d734 commit 5680901
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions doomsday/libs/doomsday/src/resource/databundle.cpp
Expand Up @@ -1463,14 +1463,15 @@ String DataBundle::cleanIdentifier(const String &text)

String DataBundle::stripVersion(const String &text, Version *version)
{
static const RegExp re(".*([-_. ]v?([0-9._-]+))$");
if (!text) return {};
static const RegExp re("(([-._]?v?)([\\d]+[-._\\d]+))$");
RegExpMatch match;
if (re.exactMatch(text, match))
if (re.match(text, match))
{
if (version)
{
String str = match.captured(2);
str.replace("_", ".");
String str = match.captured(3);
str.replace(RegExp("[-_]"), ".");
version->parseVersionString(str);
}
return text.substr(BytePos(0), text.size() - match.captured(1).size());
Expand Down

0 comments on commit 5680901

Please sign in to comment.