Skip to content

Commit

Permalink
[AssetMapper] Fix JavaScriptImportPathCompiler regex for non-latin …
Browse files Browse the repository at this point in the history
…characters
  • Loading branch information
GregRbs92 authored and fabpot committed Nov 9, 2024
1 parent 58d8b55 commit 21fe29b
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Compiler/JavaScriptImportPathCompiler.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ final class JavaScriptImportPathCompiler implements AssetCompilerInterface
)
\s*[\'"`](\.\/[^\'"`\n]++|(\.\.\/)*+[^\'"`\n]++)[\'"`]\s*[;\)]
?
/mx';
/mxu';

public function __construct(
private readonly ImportMapConfigReader $importMapConfigReader,
Expand Down
16 changes: 16 additions & 0 deletions Tests/Compiler/JavaScriptImportPathCompilerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,22 @@ public static function provideCompileTests(): iterable
'expectedJavaScriptImports' => ['/assets/other.js' => ['lazy' => false, 'asset' => 'other.js', 'add' => true]],
];

yield 'static_named_import_with_unicode_character' => [
'input' => 'import { ɵmyFunction } from "./other.js";',
'expectedJavaScriptImports' => ['/assets/other.js' => ['lazy' => false, 'asset' => 'other.js', 'add' => true]],
];

yield 'static_multiple_named_imports' => [
'input' => <<<EOF
import {
myFunction,
helperFunction
} from "./other.js";
EOF
,
'expectedJavaScriptImports' => ['/assets/other.js' => ['lazy' => false, 'asset' => 'other.js', 'add' => true]],
];

yield 'static_import_everything' => [
'input' => 'import * as myModule from "./other.js";',
'expectedJavaScriptImports' => ['/assets/other.js' => ['lazy' => false, 'asset' => 'other.js', 'add' => true]],
Expand Down

0 comments on commit 21fe29b

Please sign in to comment.