Skip to content

Commit

Permalink
Update encoding
Browse files Browse the repository at this point in the history
  • Loading branch information
PlugFox committed Nov 28, 2023
1 parent b99e3e8 commit 51ab2ea
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
6 changes: 5 additions & 1 deletion lib/src/state/state_util.dart
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,11 @@ abstract final class StateUtil {
value = _decodeComponent(element.substring(index + 1));
}
if (result[key] case String currentValue) {
result[key] = '$currentValue; $value';
if (currentValue.isEmpty) {
result[key] = value;
} else {
result[key] = '$currentValue; $value';
}
} else {
result[key] = value;
}
Expand Down
4 changes: 3 additions & 1 deletion test/octopus_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ import 'src/state_test.dart' as state_test;

void main() {
group('unit', () {
test('placeholder', () {
expect(true, isTrue);
});
state_test.main();
state_test.main(); // TODO(plugfox): remove this line
});
}
10 changes: 7 additions & 3 deletions test/src/state_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ void main() => group('state', () {
'..Profile/'
'..Settings';
expect(() => StateUtil.decodeLocation(location), returnsNormally);
print('$location\n'
/* print('$location\n'
'-->\n'
'${StateUtil.decodeLocation(location).toString()}');
'${StateUtil.decodeLocation(location).toString()}'); */
});

test('empty_url', () {
Expand Down Expand Up @@ -60,7 +60,8 @@ void main() => group('state', () {
});

test('decode_and_encode_cyrillic_state', () {
const location = 'route~name=Привет мир';
const location =
'route~name=Привет мир?теплое=Мягкое&Вкусное=кислое&флаг';
final state = StateUtil.decodeLocation(location);
expect(state.children, hasLength(1));
expect(
Expand All @@ -87,6 +88,9 @@ void main() => group('state', () {
),
),
);
expect(state.arguments['теплое'], equals('Мягкое'));
expect(state.arguments['Вкусное'], equals('кислое'));
expect(state.arguments['флаг'], isEmpty);
expect(() => state.location, returnsNormally);
});
});

0 comments on commit 51ab2ea

Please sign in to comment.