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

"/" is added at end of loaded URLs breaks GET parameters #2101

Closed
samdelong opened this issue Jul 5, 2018 · 12 comments · Fixed by #8630
Closed

"/" is added at end of loaded URLs breaks GET parameters #2101

samdelong opened this issue Jul 5, 2018 · 12 comments · Fixed by #8630
Labels

Comments

@samdelong
Copy link

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

@brian-mann
Copy link
Member

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.

@samdelong
Copy link
Author

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

@brian-mann
Copy link
Member

brian-mann commented Jul 5, 2018

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

@samdelong
Copy link
Author

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.

@brian-mann
Copy link
Member

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.

@samdelong
Copy link
Author

Excellent!

@bahmutov
Copy link
Contributor

bahmutov commented Jul 5, 2018 via email

@brian-mann brian-mann added this to the 3.0.3 milestone Jul 7, 2018
@brian-mann brian-mann modified the milestones: 3.0.3, 3.0.4 Jul 30, 2018
@jennifer-shehane jennifer-shehane removed this from the 3.0.4 milestone Aug 1, 2018
@jennifer-shehane jennifer-shehane added good first issue Good for newcomers stage: ready for work The issue is reproducible and in scope labels Aug 1, 2018
@gautamkrishnar
Copy link

@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?

@jennifer-shehane
Copy link
Member

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

@valivvvv
Copy link

valivvvv commented Jun 25, 2019

@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

ryan-snyder added a commit to ryan-snyder/cypress that referenced this issue Sep 20, 2019
@cypress-bot cypress-bot bot added stage: work in progress There is an open PR for this issue [WIP] and removed stage: ready for work The issue is reproducible and in scope labels Sep 21, 2020
@cypress-bot cypress-bot bot added stage: needs review The PR code is done & tested, needs review and removed stage: work in progress There is an open PR for this issue [WIP] labels Sep 29, 2020
@cypress-bot cypress-bot bot added stage: pending release There is a closed PR for this issue and removed stage: needs review The PR code is done & tested, needs review labels Oct 2, 2020
@cypress-bot
Copy link
Contributor

cypress-bot bot commented Oct 2, 2020

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.

@cypress-bot
Copy link
Contributor

cypress-bot bot commented Oct 14, 2020

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.

@cypress-bot cypress-bot bot removed the stage: pending release There is a closed PR for this issue label Oct 14, 2020
@cypress-bot cypress-bot bot locked as resolved and limited conversation to collaborators Oct 14, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants