diff --git a/changelogs/fragments/12063-flatpak-id-check.yml b/changelogs/fragments/12063-flatpak-id-check.yml new file mode 100644 index 0000000000..cf79636e7e --- /dev/null +++ b/changelogs/fragments/12063-flatpak-id-check.yml @@ -0,0 +1,2 @@ +bugfixes: + - flatpak - fix reporting ``changed`` on already present flatpaks with a dash in the last part of the ID (https://github.com/ansible-collections/community.general/issues/12062, https://github.com/ansible-collections/community.general/pull/12063). diff --git a/plugins/modules/flatpak.py b/plugins/modules/flatpak.py index fe3659a006..ee2898b653 100644 --- a/plugins/modules/flatpak.py +++ b/plugins/modules/flatpak.py @@ -184,6 +184,7 @@ command: sample: "/usr/bin/flatpak install --user --nontinteractive flathub org.gnome.Calculator" """ +from re import match from urllib.parse import urlparse from ansible.module_utils.basic import AnsibleModule @@ -324,15 +325,7 @@ def _is_flatpak_id(part): # https://docs.flatpak.org/en/latest/conventions.html#application-ids # Flathub: # https://docs.flathub.org/docs/for-app-authors/requirements#application-id - if "." not in part: - return False - sections = part.split(".") - if len(sections) < 2: - return False - domain = sections[0] - if not domain.islower(): - return False - return all(section.isalnum() for section in sections[1:]) + return match(r"^[a-z]{2,}(\.\w+)+\.[\w-]+$", part) def _parse_flatpak_name(name):