Skip to content

Commit

Permalink
Allow 0 as numeric identifier (#19)
Browse files Browse the repository at this point in the history
  • Loading branch information
Yanis Benson authored and sindresorhus committed Jan 25, 2020
1 parent d724367 commit c64c57f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
'use strict';
module.exports = () => /(?<=^v?|\sv?)(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)(?:-(?:[1-9]\d*|[\da-z-]*[a-z-][\da-z-]*)(?:\.(?:[1-9]\d*|[\da-z-]*[a-z-][\da-z-]*))*)?(?:\+[\da-z-]+(?:\.[\da-z-]+)*)?(?=$|\s)/ig;
module.exports = () => /(?<=^v?|\sv?)(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)(?:-(?:0|[1-9]\d*|[\da-z-]*[a-z-][\da-z-]*)(?:\.(?:0|[1-9]\d*|[\da-z-]*[a-z-][\da-z-]*))*)?(?:\+[\da-z-]+(?:\.[\da-z-]+)*)?(?=$|\s)/ig;
13 changes: 13 additions & 0 deletions test.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,3 +83,16 @@ test('#14, does not match sub-strings of longer semver-similar strings, respect
t.notRegex(string, semverRegex());
}
});

test('#18, allow 0 as numeric identifier', t => {
for (const string of [
'0.2.3-alpha.10.beta+build.unicorn.rainbow',
'1.0.3-alpha.10.beta+build.unicorn.rainbow',
'1.2.0-alpha.10.beta+build.unicorn.rainbow',
'1.2.3-0.10.beta+build.unicorn.rainbow',
'1.2.3-alpha.0.beta+build.unicorn.rainbow',
'1.2.3-alpha.10.0+build.unicorn.rainbow'
]) {
t.regex(string, semverRegex());
}
});

0 comments on commit c64c57f

Please sign in to comment.