Skip to content

Commit

Permalink
fix: Fix support for relative base path when DioOptions exist (#704)
Browse files Browse the repository at this point in the history
  • Loading branch information
huanghui1998hhh authored Sep 2, 2024
1 parent c13890c commit 06e30c3
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
7 changes: 4 additions & 3 deletions generator/lib/src/generator.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1316,9 +1316,10 @@ You should create a new class to encapsulate the response.
Map.from(extraOptions)
..[_queryParamsVar] = namedArguments[_queryParamsVar]!
..[_path] = namedArguments[_path]!
..[_baseUrlVar] = extraOptions.remove(_baseUrlVar)!.ifNullThen(
refer(_dioVar).property('options').property('baseUrl'),
),
..[_baseUrlVar] = refer('_combineBaseUrls').call([
refer(_dioVar).property('options').property('baseUrl'),
extraOptions.remove(_baseUrlVar)!,
]),
)
.cascade('data')
.assign(namedArguments[_dataVar]!);
Expand Down
5 changes: 4 additions & 1 deletion generator/test/src/generator_test_src.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1276,7 +1276,10 @@ abstract class TestModelList {
newOptions.headers.addAll(_headers);
final _options = newOptions.copyWith(
method: 'GET',
baseUrl: baseUrl ?? _dio.options.baseUrl,
baseUrl: _combineBaseUrls(
_dio.options.baseUrl,
baseUrl,
),
queryParameters: queryParameters,
path: '',
)..data = _data;
Expand Down

0 comments on commit 06e30c3

Please sign in to comment.