Cypress: "/" is added at end of loaded URLs breaks GET parameters

Created on 5 Jul 2018  Â·  12Comments  Â·  Source: cypress-io/cypress

Issue

Currently when calling .visit('url'), cypress loads it as url/, which makes the final GET parameter invalid

My cypress.json:
screenshot from 2018-07-05 11-16-37

My test.js:
screenshot from 2018-07-05 11-10-38

The loaded URL in Cypress

screenshot from 2018-07-05 11-11-23

Desired behavior:

Either don't add the extra character, or possibly add an option for removing it.

Steps to reproduce:

Screenshots above

Versions

Ran on Ubuntu 18.04, using Cypress v3.0.2

first-timers-only bug

Most helpful comment

@gautamkrishnar many baseUrls can contain url params. Take for instance one page apps, which might pass a sessionId as url param, for example. I can think of hundreds of examples.

Anyway, I found a workaround by adding an extra dummy url param at the end of my url, which cypress' visit() can break without any backslash in my app. I gave it this key value combination: &gitHubCypressIssue=2101

All 12 comments

What is making what invalid? Can you explain what you mean by the extra / is making the final GET parameter?

I get how it may look different, but under the hood the browser is actually making requests including the / as the pathname by default even when its not there. So this may be a only be a visual thing and not a functional thing.

In the electron developer console, the request is being sent with the "/", thus making it invalid as the server is expecting it without.

If you were to visit say http://example.com and pop open your dev tools then you'd see the browser making a request to / with a host of example.com.

In other words it would become: http://example.com/

Check it out in Chrome + Firefox.

Whenever you make a request that only includes the domain, the user agent will automatically add / as the pathname. So I'm unsure how this could ever be invalid with your server.

Can you explain what you mean by: "invalid"?

screen shot 2018-07-05 at 11 35 53 am
screen shot 2018-07-05 at 11 30 40 am

If you see my first screenshot, I have a GET parameter after example.com/ (https://example.com/?exam=param). The issue is the final GET parameter is send with a "/" at the end, which is invalid because it's a different value than the server is expecting.

Okay I understand now. It's because you added a param in the baseUrl. We aren't expected or parsing that. This is a bug for sure, likely easy fix.

Excellent!

Real world use cases always are more exciting than our own imagination, great find

Sent from my iPhone

On Jul 5, 2018, at 17:57, sam delong notifications@github.com wrote:

Excellent!

—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub, or mute the thread.

@jennifer-shehane @bahmutov @brian-mann This issue still exists in latest version. I am interested in fixing it. Do we really need to fix this since the baseUrl key in cypress.json should only contain top level domain without the param. It doesn't makes sense to me, how can a base url has params in it?

I'm pretty sure a good deal of the baseUrl logic is contained in this file: https://github.com/cypress-io/cypress/blob/develop/packages/driver/src/cypress/location.coffee

@gautamkrishnar many baseUrls can contain url params. Take for instance one page apps, which might pass a sessionId as url param, for example. I can think of hundreds of examples.

Anyway, I found a workaround by adding an extra dummy url param at the end of my url, which cypress' visit() can break without any backslash in my app. I gave it this key value combination: &gitHubCypressIssue=2101

The code for this is done in cypress-io/cypress#8630, but has yet to be released.
We'll update this issue and reference the changelog when it's released.

Released in 5.4.0.

This comment thread has been locked. If you are still experiencing this issue after upgrading to
Cypress v5.4.0, please open a new issue.

Was this page helpful?
0 / 5 - 0 ratings