fix(scan): strip leading dot from dot-separated version tags

VERSION_TAG_REGEX only treated whitespace, underscore, and hyphen as
separators after the version prefix, so a dot-separated tag like
"(v.1.0)" or "(Ver. 1.00)" fell through to the no-separator branch and
captured the dot into the version (".1.0", ". 1.00"). This wrong value
was then persisted to Rom.version on scan and on rename.

Add "." to the separator character class so the dot is consumed like the
other separators. Digit-prefixed tags such as "(v1.0)" are unaffected
(they still match the no-separator branch), and non-version "v*" tags are
still ignored.

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
TowyTowy
2026-07-15 11:31:52 +02:00
parent 759ebb04d8
commit aba4d0cda1
2 changed files with 19 additions and 1 deletions

View File

@@ -141,7 +141,7 @@ def _make_file_hash(
GENERIC_TAG_REGEX = re.compile(r"\(([^)]+)\)|\[([^]]+)\]")
VERSION_TAG_REGEX = re.compile(r"^(?:version|ver|v)(?:[\s_-](.*)|([.\d].*))", re.I)
VERSION_TAG_REGEX = re.compile(r"^(?:version|ver|v)(?:[\s._-](.*)|([.\d].*))", re.I)
REGION_TAG_REGEX = re.compile(r"^reg[\s|-](.*)$", re.I)
REVISION_TAG_REGEX = re.compile(r"^rev[\s|-](.*)$", re.I)

View File

@@ -241,6 +241,24 @@ class TestFSRomsHandler:
parsed_tags = handler.parse_tags(fs_name)
assert parsed_tags.version == "1.2.3"
# A dot separator (e.g. "v.1.0", "Ver. 1.00") must not leak into the
# version as a leading dot.
fs_name = "My Game (v.1.2.3).rom"
parsed_tags = handler.parse_tags(fs_name)
assert parsed_tags.version == "1.2.3"
fs_name = "My Game (Ver.1.2.3).rom"
parsed_tags = handler.parse_tags(fs_name)
assert parsed_tags.version == "1.2.3"
fs_name = "My Game (Ver. 1.00).rom"
parsed_tags = handler.parse_tags(fs_name)
assert parsed_tags.version == "1.00"
fs_name = "My Game (Version.2).rom"
parsed_tags = handler.parse_tags(fs_name)
assert parsed_tags.version == "2"
def test_parse_tags_non_version_tags_starting_with_v(self, handler: FSRomsHandler):
"""Test parse_tags keeps non-version tags starting with v as generic tags"""
fs_name = "Rom [2026] [Variation].rom"