Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
DataBundle: Improved version number detection
Single-component version numbers need a special exception so any number at the end of a file name isn't treated as a version.
  • Loading branch information
skyjake committed Jan 2, 2021
1 parent 5680901 commit e482cbb
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion doomsday/libs/doomsday/src/resource/databundle.cpp
Expand Up @@ -1464,7 +1464,7 @@ String DataBundle::cleanIdentifier(const String &text)
String DataBundle::stripVersion(const String &text, Version *version)
{
if (!text) return {};
static const RegExp re("(([-._]?v?)([\\d]+[-._\\d]+))$");
static const RegExp re("(([-._]?v?)([\\d]+[-._\\d]*))$");
RegExpMatch match;
if (re.match(text, match))
{
Expand All @@ -1473,6 +1473,15 @@ String DataBundle::stripVersion(const String &text, Version *version)
String str = match.captured(3);
str.replace(RegExp("[-_]"), ".");
version->parseVersionString(str);
if (!str.contains('.') && match.captured(2).isEmpty())
{
// Single-component version numbers without a separator must be a date.
if (version->major < 1000000)
{
*version = {};
return text;
}
}
}
return text.substr(BytePos(0), text.size() - match.captured(1).size());
}
Expand Down

0 comments on commit e482cbb

Please sign in to comment.