Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions lib/src/utils.dart
Original file line number Diff line number Diff line change
Expand Up @@ -164,9 +164,17 @@ Future<void> copyDir(String from, String to) async {
}

Future<String> getVersionListing(String package, {Uri? pubHostedUrl}) async {
final url = (pubHostedUrl ?? Uri.parse('https://pub.dartlang.org')).resolve(
'/api/packages/$package',
);
var url = (pubHostedUrl ?? Uri.parse('https://pub.dartlang.org'))
.normalizePath();
// If we have a path of only `/`
if (url.path == '/') {
url = url.replace(path: '');
}
// If there is a path, and it doesn't end in a slash we normalize to slash
if (url.path.isNotEmpty && !url.path.endsWith('/')) {
url = url.replace(path: '${url.path}/');
}
url = url.resolve('api/packages/$package');
log.fine('Downloading: $url');

return await retry(
Expand Down
Loading