question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Match query string parameters as a set of name/value pairs

See original GitHub issue

I’ve been using the WireMock record feature to create a mock of a REST API. The generation works pretty well, except that the matching of query strings in URLs seems to be a basic string equality type of match. This is fine for single parameter query strings, but means that URLs with multiple parameters MUST honour the order used in the recording (mappings), which isn’t much use. The query string should be considered as a set of (unordered) name/value pairs and matched as such.

The following URLs should be considered identical:

  • examlpe.com/path?number=1&string=hello&date=01-01-1970
  • examlpe.com/path?number=1&date=01-01-1970&string=hello
  • examlpe.com/path?string=hello&date=01-01-1970&number=1
  • examlpe.com/path?string=hello&number=1&date=01-01-1970
  • examlpe.com/path?date=01-01-1970&string=hello&number=1
  • examlpe.com/path?date=01-01-1970&number=1&string=hello

Issue Analytics

  • State:open
  • Created 7 years ago
  • Reactions:4
  • Comments:13

github_iconTop GitHub Comments

2reactions
fraserharriscommented, Sep 23, 2017

Has this been fixed? From my testing:

get(urlPathMatching("/3.0/resource/"))
                        .withQueryParam("count", WireMock.equalTo("1"))
                        .withQueryParam("offset", WireMock.equalTo("2"))
                        .withQueryParam("apikey", WireMock.equalTo(ACCESS_TOKEN)),

Creates:

{
  "urlPathPattern" : "/3.0/resource/",
  "method" : "GET",
  "queryParameters" : {
    "count" : {
      "equalTo" : "100"
    },
    "offset" : {
      "equalTo" : "1"
    },
    "apikey" : {
      "equalTo" : "mock_access_token"
    }
  }
0reactions
gr423commented, Aug 16, 2018

Hi Tom ,

I’ve created the issue #978

Thanks ,

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to Use Query Strings and Parameters for Marketers
To do this, you'll need to add a key-value pair where the key is first_name and the value will be the variable subscriber.first_name....
Read more >
4 Ways to Get Value from Query string | by bitbug
Each key of the query string will have a value, although the value may not exist. This is the same as the object...
Read more >
Regex for extracting key-value pair from HTTP Query String
I understand this data to be www-form-urlencoded, or alternatively it might be known as query string format. The object is to extract the...
Read more >
The query string (name/value pairs) is sent in the URL of a ...
Example: I need to pass a input parameter as query string in URL and need to get some data as a output according...
Read more >
Query Parameters - Routing - Ember Guides
Query params allow for additional application state to be serialized into the URL that can't otherwise fit into the path of the URL...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found