File tree Expand file tree Collapse file tree 2 files changed +25
-4
lines changed Expand file tree Collapse file tree 2 files changed +25
-4
lines changed Original file line number Diff line number Diff line change @@ -147,12 +147,21 @@ class DartUri {
147147 final packageUri = _resolvedUriToUri[uri];
148148 if (packageUri != null ) return packageUri;
149149
150- // If this is an internal app, then the given uri might be g3-relative:
150+ // If this is an internal app, then the given uri might
151+ // be relative or absolute google3 uri.
151152 if (globalToolConfiguration.appMetadata.isInternalBuild) {
152- // TODO(https://github.com/dart-lang/webdev/issues/2198): Verify if the
153- // intermediary conversion to resolvedUri is causing performance issues.
154153 final resolvedUri = _g3RelativeUriToResolvedUri[uri];
155- return _resolvedUriToUri[resolvedUri];
154+ final g3PackageUri = _resolvedUriToUri[resolvedUri];
155+ if (g3PackageUri != null ) {
156+ return g3PackageUri;
157+ }
158+
159+ // If the input is an absolute URI (like file:/// or google3:///),
160+ // return it as is, as DWDS can use it directly.
161+ final parsedUri = Uri .tryParse (uri);
162+ if (parsedUri != null && parsedUri.hasAbsolutePath) {
163+ return uri;
164+ }
156165 }
157166
158167 return null ;
Original file line number Diff line number Diff line change @@ -220,5 +220,17 @@ void main() {
220220 final resolved = DartUri .toPackageUri ('g3:///path.dart' );
221221 expect (resolved, 'package:path/path.dart' );
222222 });
223+
224+ test ('can resolve absolute file paths' , () {
225+ final absolute = 'file:///cloud/user/workspace/project/path.dart' ;
226+ final resolved = DartUri .toPackageUri (absolute);
227+ expect (resolved, absolute);
228+ });
229+
230+ test ('can resolve absolute g3 paths' , () {
231+ final absolute = 'google3:///cloud/user/workspace/project/path.dart' ;
232+ final resolved = DartUri .toPackageUri (absolute);
233+ expect (resolved, absolute);
234+ });
223235 });
224236}
You can’t perform that action at this time.
0 commit comments