kopia lustrzana https://github.com/snarfed/bridgy-fed
Web user signup: remove leading and trailing dots from domains
rodzic
04bacf0361
commit
ebb0a6c154
|
@ -476,6 +476,12 @@ class WebTest(TestCase):
|
|||
self.assertEqual('☃.net', user.key.id())
|
||||
self.assert_entities_equal(user, Web.get_by_id('☃.net'))
|
||||
|
||||
def test_get_or_create_scripts_leading_trailing_dots(self, *_):
|
||||
user = Web.get_or_create('..foo.bar.')
|
||||
self.assertEqual('foo.bar', user.key.id())
|
||||
self.assert_entities_equal(user, Web.get_by_id('foo.bar'))
|
||||
self.assertIsNone(Web.get_by_id('..foo.bar.'))
|
||||
|
||||
def test_bad_source_url(self, *mocks):
|
||||
orig_count = Object.query().count()
|
||||
|
||||
|
|
8
web.py
8
web.py
|
@ -73,8 +73,12 @@ class Web(User, Protocol):
|
|||
|
||||
@classmethod
|
||||
def get_or_create(cls, id, **kwargs):
|
||||
"""Lower cases id (domain), then passes through to :meth:`User.get_or_create`."""
|
||||
return super().get_or_create(id.lower(), **kwargs)
|
||||
"""Normalizes domain, then passes through to :meth:`User.get_or_create`.
|
||||
|
||||
Normalizing currently consists of lower casing and removing leading and
|
||||
trailing dots.
|
||||
"""
|
||||
return super().get_or_create(id.lower().strip('.'), **kwargs)
|
||||
|
||||
def web_url(self):
|
||||
"""Returns this user's web URL aka web_url, eg 'https://foo.com/'."""
|
||||
|
|
Ładowanie…
Reference in New Issue