[flutter_tools] resolve requests to web directory in debug mode (#51995)

This commit is contained in:
Jonah Williams
2020-03-05 12:34:03 -08:00
committed by GitHub
parent 374f85c976
commit bbf913bc4c
5 changed files with 48 additions and 1 deletions

View File

@@ -190,10 +190,16 @@ class WebAssetServer implements AssetReader {
// Try and resolve the path relative to the built asset directory.
if (!file.existsSync()) {
final Uri potential = globals.fs.directory(getAssetBuildDirectory())
.uri.resolve( requestPath.replaceFirst('/assets/', ''));
.uri.resolve(requestPath.replaceFirst('/assets/', ''));
file = globals.fs.file(potential);
}
if (!file.existsSync()) {
final String webPath = globals.fs.path.join(
globals.fs.currentDirectory.childDirectory('web').path, requestPath.substring(1));
file = globals.fs.file(webPath);
}
if (!file.existsSync()) {
return shelf.Response.notFound('');
}