Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[AssetMapper] Fix JavaScriptImportPathCompiler regex for non-latin characters #58659

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will break parsing non UTF8 files. My previous suggestion was made to handle such cases.
We can merge as is and wait for someone to fill in a bug, maybe UTF-8 is the only encoding found in practice?
🤷


public function __construct(
private readonly ImportMapConfigReader $importMapConfigReader,
Expand Down
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