http-mock-adapter icon indicating copy to clipboard operation
http-mock-adapter copied to clipboard

route matches ignore `baseUrl`

Open corecode opened this issue 3 years ago • 0 comments

Description

UrlRequestMatcher and MatchesRequest on RequestOptions ignore Dio's baseUrl and compare against path instead of uri.

Steps to reproduce

    test('should match baseUrl', () async {
      // arrange
      final tDio = Dio();
      final tDioAdapter = DioAdapter(dio: tDio);
      tDioAdapter.onGet(
          'http://example.com/foo/bar', (server) => server.reply(200, 'yey'));

      // act
      tDio.options.baseUrl = 'http://example.com/foo/';
      // final result = await tDio.get('http://example.com/foo/bar'); // this works
      final result = await tDio.get('bar'); // this fails

      // assert
      expect(result.data, 'yey');
    });

Expected behavior

baseUrl is considered in route matching.

corecode avatar Oct 13 '22 20:10 corecode