Commit 537b592e authored by Jonah Williams's avatar Jonah Williams Committed by Todd Volkert

fix multiroot scheme (#27914)

parent f1a8eed0
...@@ -131,7 +131,7 @@ class PackageUriMapper { ...@@ -131,7 +131,7 @@ class PackageUriMapper {
if (fileSystemScheme != null && fileSystemRoots != null && prefix.contains(fileSystemScheme)) { if (fileSystemScheme != null && fileSystemRoots != null && prefix.contains(fileSystemScheme)) {
_packageName = packageName; _packageName = packageName;
_uriPrefixes = fileSystemRoots _uriPrefixes = fileSystemRoots
.map((String name) => Uri.file('$name/lib/', windows: platform.isWindows).toString()) .map((String name) => Uri.file(name, windows: platform.isWindows).toString())
.toList(); .toList();
return; return;
} }
......
...@@ -65,12 +65,12 @@ example:file:///example/lib/ ...@@ -65,12 +65,12 @@ example:file:///example/lib/
const String multiRootPackagesContents = r''' const String multiRootPackagesContents = r'''
xml:file:///Users/flutter_user/.pub-cache/hosted/pub.dartlang.org/xml-3.2.3/lib/ xml:file:///Users/flutter_user/.pub-cache/hosted/pub.dartlang.org/xml-3.2.3/lib/
yaml:file:///Users/flutter_user/.pub-cache/hosted/pub.dartlang.org/yaml-2.1.15/lib/ yaml:file:///Users/flutter_user/.pub-cache/hosted/pub.dartlang.org/yaml-2.1.15/lib/
example:org-dartlang-app:///lib/ example:org-dartlang-app:/
'''; ''';
when(mockFile.readAsBytesSync()).thenReturn(utf8.encode(multiRootPackagesContents)); when(mockFile.readAsBytesSync()).thenReturn(utf8.encode(multiRootPackagesContents));
testUsingContext('Maps main file from same package on multiroot scheme', () async { testUsingContext('Maps main file from same package on multiroot scheme', () async {
final PackageUriMapper packageUriMapper = PackageUriMapper('/example/lib/main.dart', '.packages', 'org-dartlang-app', <String>['/example', '/gen']); final PackageUriMapper packageUriMapper = PackageUriMapper('/example/lib/main.dart', '.packages', 'org-dartlang-app', <String>['/example/lib/', '/gen/lib/']);
expect(packageUriMapper.map('/example/lib/main.dart').toString(), 'package:example/main.dart'); expect(packageUriMapper.map('/example/lib/main.dart').toString(), 'package:example/main.dart');
}, overrides: <Type, Generator>{ }, overrides: <Type, Generator>{
FileSystem: () => mockFileSystem, FileSystem: () => mockFileSystem,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment