Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

ngMock: wrong parsing of pathParams when there are queryParams #14173

Closed

Description

@marcoancona
  • Do you want to request a feature or report a bug?
    This is a bug.

  • What is the current behavior?
    httpBackend.whenRoute() does not parse correctly the path-parameters when they are immediately followed by query-parameters.

    Consider the following example:
    $httpBackend.whenRoute('DELETE', '/api/resource/:_id').respond((method, url, data, header, params) => {}

    If whenRoute is triggered by /api/resource/1?q=hello, params will contain wrong parsing of the id:

    params = {id: '1?q=hello', 'q': 'hello'}

  • What is the expected behavior?
    params = {id: '1', q: 'hello'}

  • What is the motivation / use case for changing the behavior?
    This behaviour looks wrong and inconsistent.

  • Which version of Angular, and which browser and OS does this issue affect? Did this work in previous
    versions of Angular? Please also test with the latest stable and snapshot versions.
    Angular 1.5, in previous releases params was not generated

  • Other information (e.g. detailed explanation, stacktraces, related issues, suggestions how to fix)

Activity

  1. gkalpak commented on Mar 5, 2016

    @gkalpak
    Member

    A little background:

    (Almost) the same logic is used in ngMock's parseRoute() and ngResource's pathRegExp().
    (It should be the same logic, but they seem to have gotten slightly out of sync.)

    The one intentional difference is this:

    In ngResource we match the RegExp against $location.path() (not the whole URL, containing the query). Thus we don't have to take special care to avoid matching the query.
    In ngMock, we need to have a way to ignore the query/hash part for whenRoute().

  2. added this to the 1.5.x milestone on Mar 5, 2016
  3. ferrao commented on Oct 27, 2016

    @ferrao

    👍

  4. modified the milestones: 1.5.x, 1.7.x on Apr 12, 2018
  5. added 16 commits that reference this issue on Jun 3, 2018
    c451a45
    a445526
    1abbdd2
    da157ba
    ba80a37
    fa37364
    8221685
    b57b396
    5f8485f
    f984b29
    04024ed
    7812cfb
    6ad4c84
    ad838e1
    82785e6
    6f6c180
  6. added a commit that references this issue on Jun 18, 2018
    be417f2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions