forked from organicmaps/organicmaps
Merge pull request #3720 from milchakov/MAPSME-1660_incorrect_website_validation
[editor] incorrect website validation
This commit is contained in:
commit
e7915eb557
2 changed files with 10 additions and 3 deletions
|
@ -320,9 +320,14 @@ bool EditableMapObject::ValidateWebsite(string const & site)
|
|||
if (site.empty())
|
||||
return true;
|
||||
|
||||
auto const dotPos = find(begin(site), end(site), '.');
|
||||
// Site should contain at least one dot but not at the begining/and.
|
||||
if (dotPos == end(site) || site.front() == '.' || site.back() == '.')
|
||||
// Site should contain at least one dot but not at the begining/end.
|
||||
if ('.' == site.front() || '.' == site.back())
|
||||
return false;
|
||||
|
||||
if (string::npos == site.find("."))
|
||||
return false;
|
||||
|
||||
if (string::npos != site.find(".."))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
|
|
|
@ -100,6 +100,8 @@ UNIT_TEST(EditableMapObject_ValidateWebsite)
|
|||
TEST(!EditableMapObject::ValidateWebsite(".qwerty"), ());
|
||||
TEST(!EditableMapObject::ValidateWebsite("qwerty."), ());
|
||||
TEST(!EditableMapObject::ValidateWebsite(".qwerty."), ());
|
||||
TEST(!EditableMapObject::ValidateWebsite(".qwerty."), ());
|
||||
TEST(!EditableMapObject::ValidateWebsite("w..com"), ());
|
||||
}
|
||||
|
||||
UNIT_TEST(EditableMapObject_ValidateEmail)
|
||||
|
|
Loading…
Add table
Reference in a new issue