diff --git a/src/Symfony/Component/AssetMapper/ImportMap/ImportMapVersionChecker.php b/src/Symfony/Component/AssetMapper/ImportMap/ImportMapVersionChecker.php index b0af5736eb821..6a2cf579956bd 100644 --- a/src/Symfony/Component/AssetMapper/ImportMap/ImportMapVersionChecker.php +++ b/src/Symfony/Component/AssetMapper/ImportMap/ImportMapVersionChecker.php @@ -137,7 +137,7 @@ public static function convertNpmConstraint(string $versionConstraint): ?string if (str_contains($segment, '-') && !preg_match('/-(alpha|beta|rc)\./', $segment)) { // This is a range [$start, $end] = explode('-', $segment); - $processedSegments[] = '>='.self::cleanVersionSegment(trim($start)).' <='.self::cleanVersionSegment(trim($end)); + $processedSegments[] = self::cleanVersionSegment(trim($start)).' - '.self::cleanVersionSegment(trim($end)); } elseif (preg_match('/^~(\d+\.\d+)$/', $segment, $matches)) { // Handle the tilde when only major.minor specified $baseVersion = $matches[1]; diff --git a/src/Symfony/Component/AssetMapper/Tests/ImportMap/ImportMapVersionCheckerTest.php b/src/Symfony/Component/AssetMapper/Tests/ImportMap/ImportMapVersionCheckerTest.php index 43346d3de33aa..2d6582c1d6cc4 100644 --- a/src/Symfony/Component/AssetMapper/Tests/ImportMap/ImportMapVersionCheckerTest.php +++ b/src/Symfony/Component/AssetMapper/Tests/ImportMap/ImportMapVersionCheckerTest.php @@ -261,6 +261,26 @@ public static function getCheckVersionsTests() new PackageVersionProblem('foo', 'bar', 'some/repo', '1.5.0'), ], ]; + + yield 'single with range constraint but no problem' => [ + [ + self::createRemoteEntry('foo', version: '1.0'), + self::createRemoteEntry('bar', version: '2.0.3'), + ], + [ + 'foo' => ['bar'], + 'bar' => [], + ], + [ + [ + 'url' => '/foo/1.0', + 'response' => [ + 'dependencies' => ['bar' => '1.11 - 2'], + ], + ], + ], + [], + ]; } /** @@ -297,22 +317,22 @@ public static function getNpmSpecificVersionConstraints() // Hyphen Ranges yield 'hyphen range simple' => [ '1.0.0 - 2.0.0', - '>=1.0.0 <=2.0.0', + '1.0.0 - 2.0.0', ]; yield 'hyphen range with v prefix' => [ 'v1.0.0 - 2.0.0', - '>=1.0.0 <=2.0.0', + '1.0.0 - 2.0.0', ]; yield 'hyphen range without patch' => [ '1.0 - 2.0', - '>=1.0 <=2.0', + '1.0 - 2.0', ]; yield 'hyphen range with no spaces' => [ '1.0-v2.0', - '>=1.0 <=2.0', + '1.0 - 2.0', ]; // .x Wildcards @@ -386,7 +406,7 @@ public static function getNpmSpecificVersionConstraints() yield 'multiple constraints with space and or operator' => [ '1.2.7 || 1.2.9- v2.0.0', - '1.2.7 || >=1.2.9 <=2.0.0', + '1.2.7 || 1.2.9 - 2.0.0', ]; yield 'tilde constraint with patch version no change' => [