allow {0} in search engine specification strings to allow multiple instances of the search term in the url

This commit is contained in:
haxwithaxe 2016-03-17 20:38:05 -04:00
parent f1ec6e1e00
commit eed13467f3
2 changed files with 3 additions and 1 deletions

View File

@ -1196,7 +1196,7 @@ class SearchEngineUrl(BaseType):
self._basic_validation(value) self._basic_validation(value)
if not value: if not value:
return return
elif '{}' not in value: elif not ('{}' in value or '{0}' in value):
raise configexc.ValidationError(value, "must contain \"{}\"") raise configexc.ValidationError(value, "must contain \"{}\"")
try: try:
value.format("") value.format("")

View File

@ -1726,6 +1726,8 @@ class TestSearchEngineUrl:
@pytest.mark.parametrize('val', [ @pytest.mark.parametrize('val', [
'http://example.com/?q={}', 'http://example.com/?q={}',
'http://example.com/?q={0}',
'http://example.com/?q={0}&a={0}',
'', # empty value with none_ok '', # empty value with none_ok
]) ])
def test_validate_valid(self, klass, val): def test_validate_valid(self, klass, val):