8000 Support unicode characters in importmap regex · symfony/symfony@f77c85b · GitHub
[go: up one dir, main page]

Skip to content

Commit f77c85b

Browse files
committed
Support unicode characters in importmap regex
Add the matcher \p{L} to the regex of `JavaScriptImportPathCompiler` so functions with non-latin characters still match the regex
1 parent 0b6d0e1 commit f77c85b

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

src/Symfony/Component/AssetMapper/Compiler/JavaScriptImportPathCompiler.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ final class JavaScriptImportPathCompiler implements AssetCompilerInterface
4242
(?: # Import statements (script captured)
4343
import\s*
4444
(?:
45-
(?:\*\s*as\s+\w+|\s+[\w\s{},*]+)
45+
(?:\*\s*as\s+\w+|\s+[\p{L}\w\s{},*]+)
4646
\s*from\s*
4747
)?
4848
|

src/Symfony/Component/AssetMapper/Tests/Compiler/JavaScriptImportPathCompilerTest.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,22 @@ public static function provideCompileTests(): iterable
172172
'expectedJavaScriptImports' => ['/assets/other.js' => ['lazy' => false, 'asset' => 'other.js', 'add' => true]],
173173
];
174174

175+
yield 'static_named_import_with_unicode_character' => [
176+
'input' => 'import { ɵmyFunction } from "./other.js";',
177+
'expectedJavaScriptImports' => ['/assets/other.js' => ['lazy' => false, 'asset' => 'other.js', 'add' => true]],
178+
];
179+
180+
yield 'static_multiple_named_imports' => [
181+
'input' => <<<EOF
182+
import {
183+
myFunction,
184+
helperFunction
185+
} from "./other.js";
186+
EOF
187+
,
188+
'expectedJavaScriptImports' => ['/assets/other.js' => ['lazy' => false, 'asset' => 'other.js', 'add' => true]],
189+
];
190+
175191
yield 'static_import_everything' => [
176192
'input' => 'import * as myModule from "./other.js";',
177193
'expectedJavaScriptImports' => ['/assets/other.js' => ['lazy' => false, 'asset' => 'other.js', 'add' => true]],

0 commit comments

Comments
 (0)
0