Skip to content

Commit

Permalink
Merge pull request #1 from iron3oxide/update-typeid-from-uuid-fix
Browse files Browse the repository at this point in the history
fix: Improve type prefix and suffix extraction
  • Loading branch information
iron3oxide authored May 13, 2024
2 parents 0ead5f1 + c6a4611 commit 71510ca
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions typeid/typeid.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,15 +80,12 @@ def from_uuid(suffix: uuid6.UUID, prefix: Optional[str] = None) -> TypeID:


def get_prefix_and_suffix(string: str) -> tuple:
parts = string.split("_")
prefix = None
parts = string.rsplit("_", 1)
if len(parts) == 1:
prefix = None
suffix = parts[0]
elif len(parts) == 2 and parts[0] != "":
suffix = parts[1]
prefix = parts[0]
else:
raise InvalidTypeIDStringException(f"Invalid TypeID: {string}")
prefix, suffix = parts

return prefix, suffix

Expand Down

0 comments on commit 71510ca

Please sign in to comment.