Getting the original string used to construct a semver object
Closed this issue · 2 comments
Hey,
I was wondering if it is possible to print out the original string used to construct a semver object after the object is already constructed.
Let assume I have 2 strings representing 2 tags/versions of a docker image: "4.0" and "4.0.0". If I create semver objects from them and use ToString() to print out their string representation, I will get 2 objects that both return version "4.0.0".
I am doing this in an attempt to do some sorting of the docker tags. I am aware that docker tags can be any strings and don't need to be semantically version-able, but in most of the cases semver sorting works well.
I am interested in keeping the original strings, because "4.0" and "4.0.0" might have different content in my usage context.
What can I do about it?
Just an update. I borrowed the code and made the modifications to meet the requirements.
I'm glad you were able to work around the issue. I don't think this is a use case it makes for the semver package to support. It is very much focused on representing SemVer versions per the spec. According to the spec, "4.0" isn't even a valid version. I know it is allowed because of relaxed parsing, but from the SemVer perspective it truly is identical to "4.0.0".