Coverage for apis_core/utils/normalize.py: 100%
11 statements
« prev ^ index » next coverage.py v7.6.8, created at 2024-12-20 09:24 +0000
« prev ^ index » next coverage.py v7.6.8, created at 2024-12-20 09:24 +0000
1# SPDX-FileCopyrightText: 2023 Birger Schacht
2# SPDX-License-Identifier: MIT
4import re
6from apis_core.utils.settings import dict_from_toml_directory
9def clean_uri(uri: str) -> str:
10 configs = dict_from_toml_directory("cleanuri")
11 if uri is not None:
12 for key, definition in configs.items():
13 regex = definition["regex"]
14 replace = definition["replace"]
15 if m := re.match(regex, uri):
16 uri = replace.format(m.group(1))
17 return uri