-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[dds/devtools] Switch to always using a relative base href in DevTool…
…s pages This avoids the server needing to know the exact URL path being used on the client, so proxies that rewrite the path (such as code-server) can still work. See flutter/devtools#8067 (comment) Change-Id: I5b131d84232c63f5495ccbb533da727cce514de5 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/376682 Reviewed-by: Kenzie Davisson <[email protected]> Commit-Queue: Ben Konyi <[email protected]> Reviewed-by: Ben Konyi <[email protected]>
- Loading branch information
Showing
4 changed files
with
183 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
// Copyright 2024 The Chromium Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
import 'package:dds/src/devtools/handler.dart'; | ||
import 'package:test/test.dart'; | ||
|
||
void main() { | ||
/// A set of test cases to verify base hrefs for. | ||
/// | ||
/// The key is a suffix appended to / or /devtools/ depending on how DevTools | ||
/// is hosted. | ||
/// The value is the expected base href (which should always resolve back to | ||
/// the root of where DevTools is being hosted). | ||
final testBaseHrefs = { | ||
'': '.', | ||
'inspector': '.', | ||
'inspector/': '..', | ||
'inspector/foo': '..', | ||
'inspector/foo/': '../..', | ||
'inspector/foo/bar': '../..', | ||
'inspector/foo/bar/baz': '../../..', | ||
}; | ||
|
||
for (final MapEntry(key: suffix, value: expectedBaseHref) | ||
in testBaseHrefs.entries) { | ||
test('computes correct base href for /$suffix with devtools at root', | ||
() async { | ||
final actual = computeRelativeBaseHref( | ||
'/', | ||
Uri.parse('http://localhost/$suffix'), | ||
); | ||
expect(actual, expectedBaseHref); | ||
}); | ||
|
||
test('computes correct base href for /$suffix with devtools at /devtools/', | ||
() async { | ||
final actual = computeRelativeBaseHref( | ||
'/devtools/', | ||
Uri.parse('http://localhost/devtools/$suffix'), | ||
); | ||
expect(actual, expectedBaseHref); | ||
}); | ||
|
||
test('computes correct base href for /$suffix in a devtools extension', | ||
() async { | ||
final actual = computeRelativeBaseHref( | ||
'/devtools/devtools_extension/foo/', | ||
Uri.parse('http://localhost/devtools/devtools_extension/foo/$suffix'), | ||
); | ||
expect(actual, expectedBaseHref); | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters