diff --git a/tests/test_config_domain.py b/tests/test_config_domain.py index fa256e6..aad1369 100644 --- a/tests/test_config_domain.py +++ b/tests/test_config_domain.py @@ -114,6 +114,7 @@ async def test_domainname_warning(config_type): await cfg.property.read_write() cfg = await get_config(cfg, config_type) await cfg.option('d').value.set('toto.com') + await cfg.option('d').value.set('toto.com.') with pytest.raises(ValueError): await cfg.option('d').value.set('toto') await cfg.option('d').value.set('toto3.com') diff --git a/tiramisu/option/domainnameoption.py b/tiramisu/option/domainnameoption.py index 3b90e2b..021442e 100644 --- a/tiramisu/option/domainnameoption.py +++ b/tiramisu/option/domainnameoption.py @@ -138,7 +138,11 @@ class DomainnameOption(StrOption): val = value[1:] else: val = value - for dom in val.split('.'): + if val.endswith('.'): + nval = val[:-1] + else: + nval = val + for dom in nval.split('.'): _valid_length(dom) else: _valid_length(value) @@ -179,7 +183,11 @@ class DomainnameOption(StrOption): val = value[1:] else: val = value - if not self.impl_get_extra('_domain_re').search(val): + if val.endswith('.'): + nval = val[:-1] + else: + nval = val + if not self.impl_get_extra('_domain_re').search(nval): if warnings_only: raise ValueError(self.impl_get_extra('_domain_re_message_warning')) raise ValueError(self.impl_get_extra('_domain_re_message'))