From 57ccc3cd30d94ac1d9b2a736afdf435490df5f61 Mon Sep 17 00:00:00 2001 From: George Padayatti Date: Tue, 14 May 2024 17:59:03 +0200 Subject: [PATCH] Fix: Split by camel case and concatenate by space for credential type in display for discovery Signed-off-by: George Padayatti --- .../ebsi/entry_points/server/v2_well_known.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/eudi_wallet/ebsi/entry_points/server/v2_well_known.py b/eudi_wallet/ebsi/entry_points/server/v2_well_known.py index 77b3eba..5ff6be1 100644 --- a/eudi_wallet/ebsi/entry_points/server/v2_well_known.py +++ b/eudi_wallet/ebsi/entry_points/server/v2_well_known.py @@ -1,6 +1,6 @@ from eudi_wallet.ebsi.repositories.organisation import SqlAlchemyOrganisationRepository from logging import Logger - +import re from sqlalchemy.orm import Session from eudi_wallet.ebsi.exceptions.application.organisation import ( LegalEntityNotFoundError, @@ -139,6 +139,14 @@ def validate_credential_type_based_on_disclosure_mapping( return credential +def split_camel_case_and_concatenate_by_space(s): + words = s.split() + if len(words) > 0: + return " ".join(re.findall(r"[A-Za-z][a-z]*|[A-Z]+(?=[A-Z]|$)", s)) + else: + return s + + def create_credential_supported_from_credential_offers(credential_offers: list) -> dict: credentials_supported = {} for credential_offer in credential_offers: @@ -161,7 +169,7 @@ def create_credential_supported_from_credential_offers(credential_offers: list) "cryptographic_suites_supported": ["ES256"], "display": [ { - "name": credential_types[-1], + "name": split_camel_case_and_concatenate_by_space(credential_types[-1]), "locale": "en-GB", "background_color": "#12107c", "text_color": "#FFFFFF",