-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix empty location redirects and add separate test
- Loading branch information
Showing
4 changed files
with
84 additions
and
21 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 |
---|---|---|
|
@@ -16,6 +16,7 @@ environment: | |
|
||
dependencies: | ||
http2: ^2.1.0 | ||
meta: ^1.9.1 | ||
dio: ^5.2.0 | ||
|
||
dev_dependencies: | ||
|
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,45 @@ | ||
import 'package:dio_http2_adapter/dio_http2_adapter.dart'; | ||
import 'package:test/test.dart'; | ||
|
||
void main() { | ||
group(Http2Adapter.resolveRedirectUri, () { | ||
test('empty location', () async { | ||
final current = Uri.parse('https://example.com'); | ||
final result = Http2Adapter.resolveRedirectUri( | ||
current, | ||
Uri.parse(''), | ||
); | ||
|
||
expect(result, current.toString()); | ||
}); | ||
|
||
test('relative location 1', () async { | ||
final result = Http2Adapter.resolveRedirectUri( | ||
Uri.parse('https://example.com/foo'), | ||
Uri.parse('/bar'), | ||
); | ||
|
||
expect(result, 'https://example.com/bar'); | ||
}); | ||
|
||
test('relative location 2', () async { | ||
final result = Http2Adapter.resolveRedirectUri( | ||
Uri.parse('https://example.com/foo'), | ||
Uri.parse('../bar'), | ||
); | ||
|
||
expect(result, 'https://example.com/bar'); | ||
}); | ||
|
||
test('different location', () async { | ||
final current = Uri.parse('https://example.com/foo'); | ||
final target = 'https://somewhere.com/bar'; | ||
final result = Http2Adapter.resolveRedirectUri( | ||
current, | ||
Uri.parse(target), | ||
); | ||
|
||
expect(result, target); | ||
}); | ||
}); | ||
} |