Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Namespace type check could be better #32

Closed
jace opened this issue Jun 15, 2017 · 1 comment
Closed

Namespace type check could be better #32

jace opened this issue Jun 15, 2017 · 1 comment

Comments

@jace
Copy link

jace commented Jun 15, 2017

ShortUUID determines namespace using the following code:

# If no name is given, generate a random UUID.
if name is None:
    uuid = _uu.uuid4()
elif "http" not in name.lower():
    uuid = _uu.uuid5(_uu.NAMESPACE_DNS, name)
else:
    uuid = _uu.uuid5(_uu.NAMESPACE_URL, name)

However, this should check for http:// or https:// at the beginning of the string, not anywhere in the middle, as it'll currently consider myhttpdomain.com as a URL instead of a domain. The correct if condition is: elif not name.lower().startswith(('http://', 'https://'))

@skorokithakis
Copy link
Owner

You are, of course, correct. Good shout on the tuple for startswith, too, I had never noticed that. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants