Skip to content

Commit

Permalink
Meta tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
sindresorhus committed Apr 19, 2019
1 parent 3fe447d commit 59c2292
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 19 deletions.
3 changes: 1 addition & 2 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
* text=auto
*.js text eol=lf
* text=auto eol=lf
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
language: node_js
node_js:
- '10'
- '8'
1 change: 0 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
@@ -1,3 +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;

5 changes: 2 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,12 @@
"versions",
"regex",
"regexp",
"re",
"match",
"matching",
"semantic"
],
"devDependencies": {
"ava": "*",
"xo": "*"
"ava": "^1.4.1",
"xo": "^0.24.0"
}
}
26 changes: 13 additions & 13 deletions test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import test from 'ava';
import m from '.';
import semverRegex from '.';

const fixture = [
const fixtures = [
'0.0.0',
'0.10.0',
'v1.0.0',
Expand All @@ -16,26 +16,26 @@ const fixture = [
];

test('matches semver versions on test', t => {
for (const el of fixture) {
t.regex(el, m());
for (const fixture of fixtures) {
t.regex(fixture, semverRegex());
}

t.notRegex('0.88', m());
t.notRegex('1.0.08', m());
t.notRegex('1.08.0', m());
t.notRegex('01.8.0', m());
t.notRegex('0.88', semverRegex());
t.notRegex('1.0.08', semverRegex());
t.notRegex('1.08.0', semverRegex());
t.notRegex('01.8.0', semverRegex());
});

test('returns semver on match', t => {
t.deepEqual('0.0.0'.match(m()), ['0.0.0']);
t.deepEqual('foo 0.0.0 bar 0.1.1'.match(m()), ['0.0.0', '0.1.1']);
t.deepEqual('0.0.0'.match(semverRegex()), ['0.0.0']);
t.deepEqual('foo 0.0.0 bar 0.1.1'.match(semverRegex()), ['0.0.0', '0.1.1']);
});

test('#7, does not return tag prefix', t => {
t.deepEqual('v0.0.0'.match(m()), ['0.0.0']);
t.deepEqual('v0.0.0'.match(semverRegex()), ['0.0.0']);
});

test('#14, does not match substrings of longer semver-similar strings, respect semver2.0.0 clause 9', t => {
test('#14, does not match sub-strings of longer semver-similar strings, respect semver@2.0.0 clause 9', t => {
const invalidStrings = [
'1',
'1.2',
Expand Down Expand Up @@ -80,6 +80,6 @@ test('#14, does not match substrings of longer semver-similar strings, respect s
];

for (const string of invalidStrings) {
t.notRegex(string, m());
t.notRegex(string, semverRegex());
}
});

0 comments on commit 59c2292

Please sign in to comment.