Skip to content

Commit

Permalink
Don't crash on p.toUri('') (dart-archive/path#114)
Browse files Browse the repository at this point in the history
  • Loading branch information
nex3 authored Dec 14, 2021
1 parent e089806 commit b28f107
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 2 deletions.
4 changes: 3 additions & 1 deletion pkgs/path/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
## 1.8.1-dev
## 1.8.1

* Don't crash when an empty string is passed to `toUri()`.

## 1.8.0

Expand Down
1 change: 1 addition & 0 deletions pkgs/path/lib/src/internal_style.dart
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ abstract class InternalStyle extends Style {
/// Returns the URI that represents a relative path.
@override
Uri relativePathToUri(String path) {
if (path.isEmpty) return Uri();
final segments = context.split(path);

// Ensure that a trailing slash in the path produces a trailing slash in the
Expand Down
2 changes: 1 addition & 1 deletion pkgs/path/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: path
version: 1.8.1-dev
version: 1.8.1

description: >-
A string-based path manipulation library. All of the path operations you know
Expand Down
1 change: 1 addition & 0 deletions pkgs/path/test/posix_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -590,6 +590,7 @@ void main() {
Uri.parse('file:///_%7B_%7D_%60_%5E_%20_%22_%25_'));
expect(context.toUri(r'_{_}_`_^_ _"_%_'),
Uri.parse('_%7B_%7D_%60_%5E_%20_%22_%25_'));
expect(context.toUri(''), Uri.parse(''));
});

group('prettyUri', () {
Expand Down
1 change: 1 addition & 0 deletions pkgs/path/test/url_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -871,6 +871,7 @@ void main() {
Uri.parse('http://foo.com/_%7B_%7D_%60_%5E_%20_%22_%25_'));
expect(context.toUri(r'_%7B_%7D_%60_%5E_%20_%22_%25_'),
Uri.parse('_%7B_%7D_%60_%5E_%20_%22_%25_'));
expect(context.toUri(''), Uri.parse(''));
});

group('prettyUri', () {
Expand Down
1 change: 1 addition & 0 deletions pkgs/path/test/windows_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -759,6 +759,7 @@ void main() {
Uri.parse('file:///C:/_%7B_%7D_%60_%5E_%20_%22_%25_'));
expect(context.toUri(r'_{_}_`_^_ _"_%_'),
Uri.parse('_%7B_%7D_%60_%5E_%20_%22_%25_'));
expect(context.toUri(''), Uri.parse(''));
});

group('prettyUri', () {
Expand Down

0 comments on commit b28f107

Please sign in to comment.