The Uri's replace method does not produce the correct result #56643

@nespjin

Description

Issue Description

void main() {
  final uri1 = Uri.parse('a://b?c=\${1 + 1}');
  final uri2 = uri1.replace(queryParameters: {'c': '\${1 + 1}'});
  print('uri1: ${Uri.decodeComponent(uri1.toString())}');
  print('uri2: ${Uri.decodeComponent(uri2.toString())}');

The code above prints out the following result

uri1: a://b?c=${1 + 1}
uri2: a://b?c=${1+++1}

The expected value of uri2 is the same as uri1.

Reference Information

This tracker is for issues related to:

  • Dart core libraries (dart:core.)
  • Dart Info

    If providing this information as part of reporting a bug, please review the information
    below to ensure it only contains things you're comfortable posting publicly.

    General info

  • Dart 3.3.0 (stable) (Tue Feb 13 10:25:19 2024 +0000) on "windows_x64"
  • on windows / "Windows 10 Pro" 10.0 (Build 22631)
  • locale is en-US
  • Project info

  • sdk constraint: '>=3.0.3 <4.0.0'
  • dependencies: cupertino_icons, flutter
  • dev_dependencies: build_runner, flutter_lints, flutter_test
  • elided dependencies: 2
  • Process info

    Memory Elapsed time Command line