diff --git a/src/Symfony/Component/AssetMapper/ImportMap/ImportMapManager.php b/src/Symfony/Component/AssetMapper/ImportMap/ImportMapManager.php index 6144eab323f37..eebba71d6e7ca 100644 --- a/src/Symfony/Component/AssetMapper/ImportMap/ImportMapManager.php +++ b/src/Symfony/Component/AssetMapper/ImportMap/ImportMapManager.php @@ -295,13 +295,15 @@ private function requirePackages(array $packagesToRequire, ImportMapEntries $imp $resolvedPackages = $this->resolver->resolvePackages($packagesToRequire); foreach ($resolvedPackages as $resolvedPackage) { $importName = $resolvedPackage->requireOptions->importName ?: $resolvedPackage->requireOptions->packageName; - + [$packageName, $filePath] = ImportMapConfigReader::splitPackageNameAndFilePath($importName); $newEntry = new ImportMapEntry( $importName, path: $resolvedPackage->requireOptions->path, version: $resolvedPackage->version, type: $resolvedPackage->type, isEntrypoint: $resolvedPackage->requireOptions->entrypoint, + packageName: $packageName, + filePath: $filePath, ); $importMapEntries->add($newEntry); $addedEntries[] = $newEntry; diff --git a/src/Symfony/Component/AssetMapper/ImportMap/Resolver/JsDelivrEsmResolver.php b/src/Symfony/Component/AssetMapper/ImportMap/Resolver/JsDelivrEsmResolver.php index a14a8f0ac5e7b..bdc6acc43ab98 100644 --- a/src/Symfony/Component/AssetMapper/ImportMap/Resolver/JsDelivrEsmResolver.php +++ b/src/Symfony/Component/AssetMapper/ImportMap/Resolver/JsDelivrEsmResolver.php @@ -161,6 +161,9 @@ public function downloadPackages(array $importMapEntries, callable $progressCall foreach ($importMapEntries as $package => $entry) { $pattern = ImportMapType::CSS === $entry->type ? $this->distUrlCssPattern : $this->distUrlPattern; + if (null === $entry->packageName || null === $entry->version || null === $entry->filePath) { + throw new RuntimeException(sprintf('The package "%s" cannot be downloaded. "packageName", "version" and "filePath" must be defined.', $entry->importName)); + } $url = sprintf($pattern, $entry->packageName, $entry->version, $entry->filePath); $responses[$package] = $this->httpClient->request('GET', $url); diff --git a/src/Symfony/Component/AssetMapper/Tests/ImportMap/Resolver/JsDelivrEsmResolverTest.php b/src/Symfony/Component/AssetMapper/Tests/ImportMap/Resolver/JsDelivrEsmResolverTest.php index b27ff210f0448..8b11d991c1b14 100644 --- a/src/Symfony/Component/AssetMapper/Tests/ImportMap/Resolver/JsDelivrEsmResolverTest.php +++ b/src/Symfony/Component/AssetMapper/Tests/ImportMap/Resolver/JsDelivrEsmResolverTest.php @@ -293,7 +293,7 @@ public function testDownloadPackages(array $importMapEntries, array $expectedReq public static function provideDownloadPackagesTests() { yield 'single package' => [ - ['lodash' => new ImportMapEntry('lodash', version: '1.2.3', packageName: 'lodash')], + ['lodash' => new ImportMapEntry('lodash', version: '1.2.3', packageName: 'lodash', filePath: '')], [ [ 'url' => '/lodash@1.2.3/+esm', @@ -333,7 +333,7 @@ public static function provideDownloadPackagesTests() yield 'multiple files' => [ [ - 'lodash' => new ImportMapEntry('lodash', version: '1.2.3', packageName: 'lodash'), + 'lodash' => new ImportMapEntry('lodash', version: '1.2.3', packageName: 'lodash', filePath: ''), 'chart.js/auto' => new ImportMapEntry('chart.js/auto', version: '4.5.6', packageName: 'chart.js', filePath: '/auto'), 'bootstrap/dist/bootstrap.css' => new ImportMapEntry('bootstrap/dist/bootstrap.css', version: '5.0.6', type: ImportMapType::CSS, packageName: 'bootstrap', filePath: '/dist/bootstrap.css'), ], pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy