diff --git a/src/Npm.php b/src/Npm.php index 3de19f1..a92df91 100644 --- a/src/Npm.php +++ b/src/Npm.php @@ -95,7 +95,7 @@ private function findPackagesFromCdnMatches(string $content) private function findPackagesFromLocalMatches(string $content) { - preg_match_all('/^Importmap::pin\(.+\)\;\s*\/\/\s*(.+?)@(.+?)\s+.*\r?$/m', $content, $matches); + preg_match_all('/^Importmap::pin\([\'\"](.+?)[\'\"].*\)\;\s*\/\/\s*.*@(.+?)\s+.*\r?$/m', $content, $matches); if (count($matches) !== 3) { return collect(); diff --git a/tests/fixtures/npm/audit-importmap.php b/tests/fixtures/npm/audit-importmap.php index 0ca7d4d..5485d89 100644 --- a/tests/fixtures/npm/audit-importmap.php +++ b/tests/fixtures/npm/audit-importmap.php @@ -3,4 +3,4 @@ use Tonysm\ImportmapLaravel\Facades\Importmap; Importmap::pin('is-svg', to: 'https://cdn.skypack.dev/is-svg@3.0.0', preload: true); -Importmap::pin('lodash', to: '/js/vendor/lodash.js'); // lodash@4.17.12 +Importmap::pin('lodash', to: '/js/vendor/lodash.js'); // @4.17.12 diff --git a/tests/fixtures/npm/outdated-importmap.php b/tests/fixtures/npm/outdated-importmap.php index 0c207ce..694ba55 100644 --- a/tests/fixtures/npm/outdated-importmap.php +++ b/tests/fixtures/npm/outdated-importmap.php @@ -3,4 +3,4 @@ use Tonysm\ImportmapLaravel\Facades\Importmap; Importmap::pin('is-svg', to: 'https://cdn.skypack.dev/is-svg@3.0.0', preload: true); -Importmap::pin('lodash', to: '/js/vendor/lodash.js'); // lodash@4.0.0 +Importmap::pin('lodash', to: '/js/vendor/lodash.js'); // @4.0.0