Skip to content

Commit 9e6fbcb

Browse files
Simplify trimming vm service Uris (#625)
* Simplify trimming vm service Uris * tweak changelog message
1 parent 7b9dc36 commit 9e6fbcb

File tree

3 files changed

+8
-19
lines changed

3 files changed

+8
-19
lines changed

packages/devtools/CHANGELOG.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
## 0.0.19 - 2019-05-?? (in progress)
2-
* Update DevTools server to better handle failures when launching browsers
2+
* Update DevTools server to better handle failures when launching browsers.
3+
* Support additional formats for VM service uris.
34

45
## 0.0.18 - 2019-04-30
5-
* Fix release bug (0.0.17-dev.1 did not include build folder)
6+
* Fix release bug (0.0.17-dev.1 did not include build folder).
67
* Add CPU profiler (preview) to timeline page.
78
* CPU flame chart UI improvements and bug fixes.
89
* Bug fixes for DevTools on Windows.

packages/devtools/lib/src/utils.dart

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -150,22 +150,10 @@ String longestFittingSubstring(
150150
/// For example, given a [value] of http://127.0.0.1:60667/72K34Xmq0X0=/#/vm,
151151
/// this method will return the URI http://127.0.0.1:60667/72K34Xmq0X0=/.
152152
Uri getTrimmedUri(String value) {
153-
final startingUri = Uri.parse(value);
154-
final startingPath = startingUri.path;
155-
156-
if (startingPath.isEmpty || startingPath == '/') {
157-
return Uri.parse(value);
158-
}
159-
160-
// [startingPath] should be of the form "/72K34Xmq0X0=/", but it could have
161-
// trailing characters. Trim any excess chars beyond the second slash in the
162-
// uri path.
163-
final pathParts = startingPath.split('/');
164-
final newPath = pathParts.take(2).join('/');
165-
final indexOfPath = value.indexOf(newPath);
166-
167-
// Add a trailing slash to the path.
168-
return Uri.parse(value.substring(0, indexOfPath + newPath.length) + '/');
153+
final uri = Uri.parse(value.trim());
154+
return uri
155+
.removeFragment()
156+
.replace(path: uri.path.endsWith('/') ? uri.path : '${uri.path}/');
169157
}
170158

171159
class Property<T> {

packages/devtools/test/utils_test.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ void main() {
231231
);
232232
expect(
233233
getTrimmedUri('http://127.0.0.1:60667').toString(),
234-
equals('http://127.0.0.1:60667'),
234+
equals('http://127.0.0.1:60667/'),
235235
);
236236
expect(
237237
getTrimmedUri('http://127.0.0.1:60667/').toString(),

0 commit comments

Comments
 (0)