Tweak the 'vV' replacing logic and mimic Bower and NPM behavior #123
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Those 2 commits greatly improve this plugin. I'm pasting here the commit messages as they describe pretty well what each commit does:
commit 1
Currently the 'vV' chars are replaced with str_replace,
after a preg_match. Because of how str_replace works, this could
lead to some potential bugs. Replace with a single preg_replace
that will handle the job in exactly the same way.
As a side bonus, we're getting rid of a loop, which could speed
up things a little bit.
commit 2
Mimic the behavior of NPM and Bower when comparing versions
constructed by 1 or 2 groups of numbers.
Versions as "1", "7.9", "v4" and "v98.2" are perfectly valid
and both Bower and NPM expand those to, accordingly, "1.",
"7.9.", "v4." and "v98.2.". Until now this plugin
failed at doing so, which causes quite some failures when
trying to install packages that use that syntax (npmconf,
just to name one).
This commit fixes that by adding a single regex replace
that matches 1 or 2 groups of numbers and appends an ".*".
Also, the regex keeps in mind that other type of versions,
such as "~2" or ">=4.5" don't need to be expanded.
Also note that this fix will not break current unit
tests.