Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
32db0fe7
Unverified
Commit
32db0fe7
authored
Jan 22, 2021
by
Jonah Williams
Committed by
GitHub
Jan 22, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[flutter_tools] provide correct sources and metadata for different base hrefs (#74452)
parent
08068fd9
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
1 deletion
+25
-1
devfs_web.dart
packages/flutter_tools/lib/src/isolated/devfs_web.dart
+4
-1
devfs_web_test.dart
.../flutter_tools/test/general.shard/web/devfs_web_test.dart
+21
-0
No files found.
packages/flutter_tools/lib/src/isolated/devfs_web.dart
View file @
32db0fe7
...
...
@@ -552,6 +552,7 @@ class WebAssetServer implements AssetReader {
@override
Future
<
String
>
dartSourceContents
(
String
serverPath
)
async
{
serverPath
=
_stripBasePath
(
serverPath
,
basePath
);
final
File
result
=
_resolveDartFile
(
serverPath
);
if
(
result
.
existsSync
())
{
return
result
.
readAsString
();
...
...
@@ -561,18 +562,20 @@ class WebAssetServer implements AssetReader {
@override
Future
<
String
>
sourceMapContents
(
String
serverPath
)
async
{
serverPath
=
_stripBasePath
(
serverPath
,
basePath
);
return
utf8
.
decode
(
_webMemoryFS
.
sourcemaps
[
serverPath
]);
}
@override
Future
<
String
>
metadataContents
(
String
serverPath
)
async
{
serverPath
=
_stripBasePath
(
serverPath
,
basePath
);
if
(
serverPath
==
'main_module.ddc_merged_metadata'
)
{
return
_webMemoryFS
.
mergedMetadata
;
}
if
(
_webMemoryFS
.
metadataFiles
.
containsKey
(
serverPath
))
{
return
utf8
.
decode
(
_webMemoryFS
.
metadataFiles
[
serverPath
]);
}
return
null
;
throw
Exception
(
'Could not find metadata contents for
$serverPath
'
)
;
}
@override
...
...
packages/flutter_tools/test/general.shard/web/devfs_web_test.dart
View file @
32db0fe7
...
...
@@ -1003,6 +1003,27 @@ void main() {
expect
(
response
.
statusCode
,
404
);
}));
test
(
'WebAssetServer strips leading base href off off asset requests'
,
()
=>
testbed
.
run
(()
async
{
const
String
htmlContent
=
'<html><head><base href="/foo/"></head><body id="test"></body></html>'
;
globals
.
fs
.
currentDirectory
.
childDirectory
(
'web'
)
.
childFile
(
'index.html'
)
..
createSync
(
recursive:
true
)
..
writeAsStringSync
(
htmlContent
);
final
WebAssetServer
webAssetServer
=
WebAssetServer
(
MockHttpServer
(),
PackageConfig
.
empty
,
InternetAddress
.
anyIPv4
,
<
String
,
String
>{},
<
String
,
String
>{},
NullSafetyMode
.
sound
,
);
expect
(
await
webAssetServer
.
metadataContents
(
'foo/main_module.ddc_merged_metadata'
),
null
);
// Not base href.
expect
(()
async
=>
await
webAssetServer
.
metadataContents
(
'bar/main_module.ddc_merged_metadata'
),
throwsException
);
}));
test
(
'DevFS URI includes any specified base path.'
,
()
=>
testbed
.
run
(()
async
{
final
File
outputFile
=
globals
.
fs
.
file
(
globals
.
fs
.
path
.
join
(
'lib'
,
'main.dart'
))
..
createSync
(
recursive:
true
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment