From 8650854c77ca7d1efe2486b406710b1b0c391e1d Mon Sep 17 00:00:00 2001 From: Klemen Tusar Date: Sat, 13 Apr 2024 11:27:11 +0100 Subject: [PATCH] :bug: disable `decodeDotInKeys` by default to restore previous behavior (#4) --- lib/src/models/decode_options.dart | 2 +- test/unit/decode_test.dart | 20 ++++++++++++++++++++ test/unit/models/decode_options_test.dart | 2 +- 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/lib/src/models/decode_options.dart b/lib/src/models/decode_options.dart index 8cd7993..8eb1a38 100644 --- a/lib/src/models/decode_options.dart +++ b/lib/src/models/decode_options.dart @@ -26,7 +26,7 @@ final class DecodeOptions with EquatableMixin { this.parseLists = true, this.strictNullHandling = false, }) : allowDots = allowDots ?? decodeDotInKeys == true || false, - decodeDotInKeys = decodeDotInKeys ?? true, + decodeDotInKeys = decodeDotInKeys ?? false, _decoder = decoder, assert( charset == utf8 || charset == latin1, diff --git a/test/unit/decode_test.dart b/test/unit/decode_test.dart index c224e44..6c4dbb9 100644 --- a/test/unit/decode_test.dart +++ b/test/unit/decode_test.dart @@ -210,6 +210,26 @@ void main() { 'name.obj.subobject': {'first.godly.name': 'John', 'last': 'Doe'} }), ); + expect( + QS.decode('name%252Eobj.first=John&name%252Eobj.last=Doe'), + equals({'name%2Eobj.first': 'John', 'name%2Eobj.last': 'Doe'}), + ); + expect( + QS.decode( + 'name%252Eobj.first=John&name%252Eobj.last=Doe', + const DecodeOptions(decodeDotInKeys: false), + ), + equals({'name%2Eobj.first': 'John', 'name%2Eobj.last': 'Doe'}), + ); + expect( + QS.decode( + 'name%252Eobj.first=John&name%252Eobj.last=Doe', + const DecodeOptions(decodeDotInKeys: true), + ), + equals({ + 'name.obj': {'first': 'John', 'last': 'Doe'} + }), + ); }); test( diff --git a/test/unit/models/decode_options_test.dart b/test/unit/models/decode_options_test.dart index 80bfd29..a6ca091 100644 --- a/test/unit/models/decode_options_test.dart +++ b/test/unit/models/decode_options_test.dart @@ -122,7 +122,7 @@ void main() { ' charset: Instance of \'Latin1Codec\',\n' ' charsetSentinel: true,\n' ' comma: true,\n' - ' decodeDotInKeys: true,\n' + ' decodeDotInKeys: false,\n' ' delimiter: ,,\n' ' depth: 10,\n' ' duplicates: combine,\n'