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
e870f5d1
Unverified
Commit
e870f5d1
authored
Apr 01, 2021
by
Jonah Williams
Committed by
GitHub
Apr 01, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[flutter_tools] use Url path.Context for joining URI (#79566)
parent
66af44c9
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
28 additions
and
2 deletions
+28
-2
utils.dart
packages/flutter_tools/lib/src/base/utils.dart
+4
-0
vmservice.dart
packages/flutter_tools/lib/src/vmservice.dart
+11
-2
vmservice_test.dart
...ages/flutter_tools/test/general.shard/vmservice_test.dart
+13
-0
No files found.
packages/flutter_tools/lib/src/base/utils.dart
View file @
e870f5d1
...
@@ -7,9 +7,13 @@ import 'dart:math' as math;
...
@@ -7,9 +7,13 @@ import 'dart:math' as math;
import
'package:intl/intl.dart'
;
import
'package:intl/intl.dart'
;
import
'package:file/file.dart'
;
import
'package:file/file.dart'
;
import
'package:path/path.dart'
as
path
;
// flutter_ignore: package_path_import
import
'../convert.dart'
;
import
'../convert.dart'
;
/// A path jointer for URL paths.
final
path
.
Context
urlContext
=
path
.
url
;
/// Convert `foo_bar` to `fooBar`.
/// Convert `foo_bar` to `fooBar`.
String
camelCase
(
String
str
)
{
String
camelCase
(
String
str
)
{
int
index
=
str
.
indexOf
(
'_'
);
int
index
=
str
.
indexOf
(
'_'
);
...
...
packages/flutter_tools/lib/src/vmservice.dart
View file @
e870f5d1
...
@@ -7,13 +7,14 @@
...
@@ -7,13 +7,14 @@
import
'dart:async'
;
import
'dart:async'
;
import
'package:file/file.dart'
;
import
'package:file/file.dart'
;
import
'package:meta/meta.dart'
show
required
;
import
'package:meta/meta.dart'
show
required
,
visibleForTesting
;
import
'package:vm_service/vm_service.dart'
as
vm_service
;
import
'package:vm_service/vm_service.dart'
as
vm_service
;
import
'base/common.dart'
;
import
'base/common.dart'
;
import
'base/context.dart'
;
import
'base/context.dart'
;
import
'base/io.dart'
as
io
;
import
'base/io.dart'
as
io
;
import
'base/logger.dart'
;
import
'base/logger.dart'
;
import
'base/utils.dart'
;
import
'build_info.dart'
;
import
'build_info.dart'
;
import
'convert.dart'
;
import
'convert.dart'
;
import
'device.dart'
;
import
'device.dart'
;
...
@@ -39,6 +40,14 @@ typedef PrintStructuredErrorLogMethod = void Function(vm_service.Event);
...
@@ -39,6 +40,14 @@ typedef PrintStructuredErrorLogMethod = void Function(vm_service.Event);
WebSocketConnector
_openChannel
=
_defaultOpenChannel
;
WebSocketConnector
_openChannel
=
_defaultOpenChannel
;
/// A testing only override of the WebSocket connector.
///
/// Provide a `null` value to restore the original connector.
@visibleForTesting
set
openChannelForTesting
(
WebSocketConnector
connector
)
{
_openChannel
=
connector
??
_defaultOpenChannel
;
}
/// The error codes for the JSON-RPC standard, including VM service specific
/// The error codes for the JSON-RPC standard, including VM service specific
/// error codes.
/// error codes.
///
///
...
@@ -322,7 +331,7 @@ Future<FlutterVmService> _connect(
...
@@ -322,7 +331,7 @@ Future<FlutterVmService> _connect(
io
.
CompressionOptions
compression
=
io
.
CompressionOptions
.
compressionDefault
,
io
.
CompressionOptions
compression
=
io
.
CompressionOptions
.
compressionDefault
,
Device
device
,
Device
device
,
})
async
{
})
async
{
final
Uri
wsUri
=
httpUri
.
replace
(
scheme:
'ws'
,
path:
globals
.
fs
.
path
.
join
(
httpUri
.
path
,
'ws'
));
final
Uri
wsUri
=
httpUri
.
replace
(
scheme:
'ws'
,
path:
urlContext
.
join
(
httpUri
.
path
,
'ws'
));
final
io
.
WebSocket
channel
=
await
_openChannel
(
wsUri
.
toString
(),
compression:
compression
);
final
io
.
WebSocket
channel
=
await
_openChannel
(
wsUri
.
toString
(),
compression:
compression
);
final
vm_service
.
VmService
delegateService
=
vm_service
.
VmService
(
final
vm_service
.
VmService
delegateService
=
vm_service
.
VmService
(
channel
,
channel
,
...
...
packages/flutter_tools/test/general.shard/vmservice_test.dart
View file @
e870f5d1
...
@@ -643,6 +643,19 @@ void main() {
...
@@ -643,6 +643,19 @@ void main() {
expect
(
processVmServiceMessage
(
event
),
'Hello There'
);
expect
(
processVmServiceMessage
(
event
),
'Hello There'
);
});
});
testUsingContext
(
'WebSocket URL construction uses correct URI join primitives'
,
()
async
{
final
Completer
<
String
>
completer
=
Completer
<
String
>();
openChannelForTesting
=
(
String
url
,
{
io
.
CompressionOptions
compression
})
async
{
completer
.
complete
(
url
);
throw
Exception
(
''
);
};
// Construct a URL that does not end in a `/`.
await
expectLater
(()
=>
connectToVmService
(
Uri
.
parse
(
'http://localhost:8181/foo'
)),
throwsException
);
expect
(
await
completer
.
future
,
'ws://localhost:8181/foo/ws'
);
openChannelForTesting
=
null
;
});
}
}
class
MockVMService
extends
Fake
implements
vm_service
.
VmService
{
class
MockVMService
extends
Fake
implements
vm_service
.
VmService
{
...
...
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