-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #10 from InvisibleSmiley/Issue-9
Fix splitting version strings with userinfo in URL
- Loading branch information
Showing
2 changed files
with
66 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -218,21 +218,65 @@ public function testYarnExampleArray() | |
} | ||
|
||
/** | ||
* Scoped packages names should not be split at the first '@' | ||
* The parser should split the package name and version parts | ||
* | ||
* Scoped packages names (prefixed with @) and Git version references should be detected properly. | ||
* | ||
* @param string $versionString | ||
* @param array{string, string} $expectedResult | ||
* @dataProvider provideVersionsForSplitting | ||
* @return void | ||
*/ | ||
public function testVersionSplitting() | ||
public function testVersionSplitting($versionString, array $expectedResult) | ||
{ | ||
static::assertSame( | ||
['gulp-sourcemaps', '2.6.4'], | ||
Parser::splitVersionString('[email protected]') | ||
); | ||
self::assertSame($expectedResult, Parser::splitVersionString($versionString)); | ||
} | ||
|
||
static::assertSame( | ||
['@gulp-sourcemaps/identity-map', '1.X'], | ||
Parser::splitVersionString('@gulp-sourcemaps/[email protected]') | ||
); | ||
/** | ||
* @return array<string, array{ | ||
* versionString: string, | ||
* expectedResult: array{string, string} | ||
* }> | ||
*/ | ||
public static function provideVersionsForSplitting(): array | ||
{ | ||
return [ | ||
'simple package, simple version' => [ | ||
'versionString' => '[email protected]', | ||
'expectedResult' => ['gulp-sourcemaps', '2.6.4'], | ||
], | ||
'namespaced package, simple version' => [ | ||
'versionString' => '@gulp-sourcemaps/[email protected]', | ||
'expectedResult' => ['@gulp-sourcemaps/identity-map', '1.X'], | ||
], | ||
'simple package, Git semver reference' => [ | ||
'versionString' => 'foo-bar@git+ssh://user@host:1234/foo/bar#semver:^1.2.3', | ||
'expectedResult' => ['foo-bar', 'git+ssh://user@host:1234/foo/bar#semver:^1.2.3'], | ||
], | ||
'namespaced package, Git semver reference' => [ | ||
'versionString' => '@foo/bar@git+ssh://user@host:1234/foo/bar#semver:^1.2.3', | ||
'expectedResult' => ['@foo/bar', 'git+ssh://user@host:1234/foo/bar#semver:^1.2.3'], | ||
], | ||
'simple package, Git tag reference' => [ | ||
'versionString' => 'foo-bar@git://user@host/foo/bar.git#v1.2.3', | ||
'expectedResult' => ['foo-bar', 'git://user@host/foo/bar.git#v1.2.3'], | ||
], | ||
'namespaced package, Git tag reference' => [ | ||
'versionString' => '@foo/bar@git://user@host/foo/bar.git#v1.2.3', | ||
'expectedResult' => ['@foo/bar', 'git://user@host/foo/bar.git#v1.2.3'], | ||
], | ||
'simple package, file reference' => [ | ||
'versionString' => 'foo-bar@file:vendor/foo/bar', | ||
'expectedResult' => ['foo-bar', 'file:vendor/foo/bar'], | ||
], | ||
'namespaced package, file reference' => [ | ||
'versionString' => '@foo/bar@file:vendor/foo/bar', | ||
'expectedResult' => ['@foo/bar', 'file:vendor/foo/bar'], | ||
], | ||
]; | ||
} | ||
|
||
|
||
/** | ||
* Single-value keys should not be split at spaces if they are surrounded with quotes | ||
* @throws ParserException | ||
|