Skip to content

Commit f4b365e

Browse files
authored
Remove dependency on package:path (#865)
1 parent 8386923 commit f4b365e

File tree

4 files changed

+6
-7
lines changed

4 files changed

+6
-7
lines changed

pkgs/http/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
## 0.13.6-dev
22

33
* `BrowserClient` throws an exception if `send` is called after `close`.
4+
* No longer depends on package:path.
45

56
## 0.13.5
67

pkgs/http/lib/src/multipart_file_io.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@
55
import 'dart:io';
66

77
import 'package:http_parser/http_parser.dart';
8-
import 'package:path/path.dart' as p;
98

109
import 'byte_stream.dart';
1110
import 'multipart_file.dart';
1211

1312
Future<MultipartFile> multipartFileFromPath(String field, String filePath,
1413
{String? filename, MediaType? contentType}) async {
15-
filename ??= p.basename(filePath);
14+
late var segments = Uri.file(filePath).pathSegments;
15+
filename ??= segments.isEmpty ? '' : segments.last;
1616
var file = File(filePath);
1717
var length = await file.length();
1818
var stream = ByteStream(file.openRead());

pkgs/http/pubspec.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ dependencies:
1010
async: ^2.5.0
1111
http_parser: ^4.0.0
1212
meta: ^1.3.0
13-
path: ^1.8.0
1413

1514
dev_dependencies:
1615
fake_async: ^1.2.0

pkgs/http/test/io/multipart_test.dart

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
import 'dart:io';
88

99
import 'package:http/http.dart' as http;
10-
import 'package:path/path.dart' as path;
1110
import 'package:test/test.dart';
1211

1312
import '../utils.dart';
@@ -21,9 +20,9 @@ void main() {
2120
tearDown(() => tempDir.deleteSync(recursive: true));
2221

2322
test('with a file from disk', () async {
24-
var filePath = path.join(tempDir.path, 'test-file');
25-
File(filePath).writeAsStringSync('hello');
26-
var file = await http.MultipartFile.fromPath('file', filePath);
23+
var fileUri = tempDir.uri.resolve('test-file');
24+
File.fromUri(fileUri).writeAsStringSync('hello');
25+
var file = await http.MultipartFile.fromPath('file', fileUri.toFilePath());
2726
var request = http.MultipartRequest('POST', dummyUrl);
2827
request.files.add(file);
2928

0 commit comments

Comments
 (0)