mirror of
https://github.com/rommapp/romm.git
synced 2026-03-03 02:57:01 +00:00
Merge pull request #3035 from rommapp/romm-3026
[ROMM-3026] Region/language shortcodes should be case sensitive
This commit is contained in:
@@ -83,10 +83,10 @@ REGIONS = (
|
|||||||
("W", "World"),
|
("W", "World"),
|
||||||
)
|
)
|
||||||
|
|
||||||
REGIONS_BY_SHORTCODE = {region[0].lower(): region[1] for region in REGIONS}
|
REGIONS_BY_SHORTCODE = {region[0]: region[1] for region in REGIONS}
|
||||||
REGIONS_NAME_KEYS = frozenset(region[1].lower() for region in REGIONS)
|
REGIONS_NAME_KEYS = frozenset(region[1].lower() for region in REGIONS)
|
||||||
|
|
||||||
LANGUAGES_BY_SHORTCODE = {lang[0].lower(): lang[1] for lang in LANGUAGES}
|
LANGUAGES_BY_SHORTCODE = {lang[0]: lang[1] for lang in LANGUAGES}
|
||||||
LANGUAGES_NAME_KEYS = frozenset(lang[1].lower() for lang in LANGUAGES)
|
LANGUAGES_NAME_KEYS = frozenset(lang[1].lower() for lang in LANGUAGES)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -334,46 +334,46 @@ class FSRomsHandler(FSHandler):
|
|||||||
regions, languages, other_tags = [], [], []
|
regions, languages, other_tags = [], [], []
|
||||||
version = revision = ""
|
version = revision = ""
|
||||||
|
|
||||||
for raw in tags:
|
for raw_tag in tags:
|
||||||
tag = raw.lower()
|
lower_tag = raw_tag.lower()
|
||||||
|
|
||||||
# Region by code
|
# Region by code
|
||||||
if tag in REGIONS_BY_SHORTCODE.keys():
|
if raw_tag in REGIONS_BY_SHORTCODE.keys():
|
||||||
regions.append(REGIONS_BY_SHORTCODE[tag])
|
regions.append(REGIONS_BY_SHORTCODE[raw_tag])
|
||||||
continue
|
continue
|
||||||
if tag in REGIONS_NAME_KEYS:
|
if lower_tag in REGIONS_NAME_KEYS:
|
||||||
regions.append(raw)
|
regions.append(raw_tag)
|
||||||
continue
|
continue
|
||||||
|
|
||||||
# Language by code
|
# Language by code
|
||||||
if tag in LANGUAGES_BY_SHORTCODE.keys():
|
if raw_tag in LANGUAGES_BY_SHORTCODE.keys():
|
||||||
languages.append(LANGUAGES_BY_SHORTCODE[tag])
|
languages.append(LANGUAGES_BY_SHORTCODE[raw_tag])
|
||||||
continue
|
continue
|
||||||
if tag in LANGUAGES_NAME_KEYS:
|
if lower_tag in LANGUAGES_NAME_KEYS:
|
||||||
languages.append(raw)
|
languages.append(raw_tag)
|
||||||
continue
|
continue
|
||||||
|
|
||||||
# Version
|
# Version
|
||||||
version_match = VERSION_TAG_REGEX.match(raw)
|
version_match = VERSION_TAG_REGEX.match(raw_tag)
|
||||||
if version_match:
|
if version_match:
|
||||||
version = version_match[1]
|
version = version_match[1]
|
||||||
continue
|
continue
|
||||||
|
|
||||||
# Region prefix
|
# Region prefix
|
||||||
region_match = REGION_TAG_REGEX.match(raw)
|
region_match = REGION_TAG_REGEX.match(raw_tag)
|
||||||
if region_match:
|
if region_match:
|
||||||
key = region_match[1].lower()
|
key = region_match[1].lower()
|
||||||
regions.append(REGIONS_BY_SHORTCODE.get(key, region_match[1]))
|
regions.append(REGIONS_BY_SHORTCODE.get(key, region_match[1]))
|
||||||
continue
|
continue
|
||||||
|
|
||||||
# Revision prefix
|
# Revision prefix
|
||||||
revision_match = REVISION_TAG_REGEX.match(raw)
|
revision_match = REVISION_TAG_REGEX.match(raw_tag)
|
||||||
if revision_match:
|
if revision_match:
|
||||||
revision = revision_match[1]
|
revision = revision_match[1]
|
||||||
continue
|
continue
|
||||||
|
|
||||||
# Anything else
|
# Anything else
|
||||||
other_tags.append(raw)
|
other_tags.append(raw_tag)
|
||||||
|
|
||||||
return ParsedTags(
|
return ParsedTags(
|
||||||
version=version,
|
version=version,
|
||||||
|
|||||||
Reference in New Issue
Block a user