Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mangled URL's #58

Closed
bryanlarsen opened this issue Oct 1, 2020 · 4 comments
Closed

mangled URL's #58

bryanlarsen opened this issue Oct 1, 2020 · 4 comments
Assignees

Comments

@bryanlarsen
Copy link

bryanlarsen commented Oct 1, 2020

This fragment of HAR:

"request": {
          "method": "GET",
          "url": "https://example.com/api/layers/layer?assetId=bdaed40b-bed9-4b6f-abc4-56093ed1a43c&assetLayer=a9f5d33e-ab3b-4435-b3f6-427bc5aeb9c1&assetLayerConfiguration={%22Fabric%22:{%22assetId%22:%22bcff95a5-1b8c-4bad-a238-d8d6ca9c76ac%22},%22Collar%22:{%22assetId%22:%224c6b7595-083c-4905-a8f9-ae62d6a89c0e%22},%22Cuff%22:{%22assetId%22:%22acba39b1-05e7-43ae-bf80-1305a3a9277e%22},%22Pocket%22:{%22assetId%22:%2223eb7c46-b9da-4b68-80fa-d12971d46a93%22}}&orgId=0f556303-22e6-4015-b3b7-17438a673967",
          "queryString": [
            {
              "name": "assetId",
              "value": "bdaed40b-bed9-4b6f-abc4-56093ed1a43c"
            },
            {
              "name": "assetLayer",
              "value": "a9f5d33e-ab3b-4435-b3f6-427bc5aeb9c1"
            },
            {
              "name": "assetLayerConfiguration",
              "value": "{%22Fabric%22:{%22assetId%22:%22bcff95a5-1b8c-4bad-a238-d8d6ca9c76ac%22},%22Collar%22:{%22assetId%22:%224c6b7595-083c-4905-a8f9-ae62d6a89c0e%22},%22Cuff%22:{%22assetId%22:%22acba39b1-05e7-43ae-bf80-1305a3a9277e%22},%22Pocket%22:{%22assetId%22:%2223eb7c46-b9da-4b68-80fa-d12971d46a93%22}}"
            },
            {
              "name": "orgId",
              "value": "0f556303-22e6-4015-b3b7-17438a673967"
            },
          ],

gets converted into:

      response = http.get(
           "https://example.com/api/layers/layer?assetId=bdaed40b-bed9-4b6f-abc4-56093ed1a43c&assetLayer=a9f5d33e-ab3b-4435-b3f6-427bc5aeb9c1&assetLayerConfiguration=%7B%22Fabric%22%3A%7B%22assetId%22%3A%22bcff95a5-1b8c-4bad-a238-d8d6ca9c76ac%22%7D%2C%22Collar%22%3A%7B%22assetId%22%3A%224c6b7595-083c-4905-a8f9-ae62d6a89c0e%22%7D%2C%22Cuff%22%3A%7B%22assetId%22%3A%22acba39b1-05e7-43ae-bf80-1305a3a9277e%22%7D%2C%22Pocket%22%3A%7B%22assetId%22%3A%2223eb7c46-b9da-4b68-80fa-d12971d46a93%22%7D%7D&assetLayerConfiguration=%7B%2522Fabric%2522%3A%7B%2522assetId%2522%3A%2522bcff95a5-1b8c-4bad-a238-d8d6ca9c76ac%2522%7D%2C%2522Collar%2522%3A%7B%2522assetId%2522%3A%25224c6b7595-083c-4905-a8f9-ae62d6a89c0e%2522%7D%2C%2522Cuff%2522%3A%7B%2522assetId%2522%3A%2522acba39b1-05e7-43ae-bf80-1305a3a9277e%2522%7D%2C%2522Pocket%2522%3A%7B%2522assetId%2522%3A%252223eb7c46-b9da-4b68-80fa-d12971d46a93%2522%7D%7D&orgId=0f556303-22e6-4015-b3b7-17438a673967",

Notice how some query string parameters get added twice and the second time they're added they get double URI encoded.

@bryanlarsen bryanlarsen changed the title URL's doubly URI enoded mangled URL's Oct 1, 2020
@bryanlarsen
Copy link
Author

hack fix:

diff --git a/src/parse/request.js b/src/parse/request.js
index 674d9e8..b2faac1 100644
--- a/src/parse/request.js
+++ b/src/parse/request.js
@@ -10,9 +10,9 @@ function request(node, spec) {
   if (node.comment) {
     spec.comment = node.comment
   }
-  if (node.queryString) {
-    queryString(node.queryString, spec.query)
-  }
+//  if (node.queryString) {
+//    queryString(node.queryString, spec.query)
+//  }
   if (node.headers) {
     headers(node.headers, spec.headers)
   }

@legander
Copy link
Collaborator

legander commented Nov 6, 2020

Looks like the HAR fragment you have provided includes the query parameters both in the url field and in the queryString field.
To avoid duplication only one or the other should be provided.

Possible solution could be to deserialize the URL and create a new list with unique kv-pairs from the URLSearchParams + queryString.

@bryanlarsen
Copy link
Author

The HAR file came from Chrome.

@legander
Copy link
Collaborator

legander commented Nov 6, 2020

Yeah I figured.. Thanks for creating the issue.
I have schedules this for next coming weeks 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants