summaryrefslogtreecommitdiff
path: root/semantic_version/base.py
diff options
context:
space:
mode:
Diffstat (limited to 'semantic_version/base.py')
-rw-r--r--semantic_version/base.py8
1 files changed, 8 insertions, 0 deletions
diff --git a/semantic_version/base.py b/semantic_version/base.py
index 1b0bac5..7fd871e 100644
--- a/semantic_version/base.py
+++ b/semantic_version/base.py
@@ -244,6 +244,14 @@ class Version(object):
while version.count('.') < 2:
version += '.0'
+ # Strip leading zeros in components
+ # Version is of the form nn, nn.pp or nn.pp.qq
+ version = '.'.join(
+ # If the part was '0', we end up with an empty string.
+ part.lstrip('0') or '0'
+ for part in version.split('.')
+ )
+
if match.end() == len(version_string):
return Version(version, partial=partial)