cypress-io / cypress

Fast, easy and reliable testing for anything that runs in a browser.
https://cypress.io
MIT License
47.02k stars 3.19k forks source link

A forward slash '/' is stripped from the query paramaters on the request #9360

Closed rwindt closed 3 years ago

rwindt commented 3 years ago

Current behavior

When using cy.request() for a path without a hostname the trailing / is deleted from the query parameters. In test we use, we have a baseUrl, and per test we add the path.

For example we have defined the baseUrl www.test.url(please use a working url, this is only used as an example) and in the test we have cy.request('/pageOne?param1=/param/') then the following is executed in Cypress request GET 200 http://www.test.url/pageOne?param1=/param. The last / is deleted. This test started to fail since the introduction of Cypress 5.4.0, I think it could be related to this issue https://github.com/cypress-io/cypress/issues/2101

Desired behavior

Desired behaviour is that the trailing / is not deleted from the given path.

Test code to reproduce

cy.request(`/pageOne?param1=/param/`)

Do have a baseUrl set.

Versions

Worked on 5.3.0 Started to fail from 5.4.0 onwards

jennifer-shehane commented 3 years ago

To reproduce this doesn't require having a baseUrl set. This behavior change was introduced in 5.4.0 in https://github.com/cypress-io/cypress/pull/8630 cc @sainthkh

Issue present: https://github.com/cypress-io/cypress/commit/b86b26e1b6014a380e42b6e5d80d7ec2974db0dc Issue not present: https://github.com/cypress-io/cypress/commit/d28676c43eb341aff38adfe2ccbef4253b4ba95a

it('request slash', () => {
  cy.visit('index.html')
  // requests to /pageOne?param1=/param/ in 5.3.0
  // requests to /pageOne?param1=/param in 5.4.0+
  cy.request('/pageOne?param1=/param/')
})

5.3.0

Screen Shot 2020-11-30 at 10 26 49 AM

5.4.0

Screen Shot 2020-11-30 at 10 28 22 AM
cypress-bot[bot] commented 3 years ago

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

rwindt commented 3 years ago

Very nice! And what a speed, keep up the good work!

cypress-bot[bot] commented 3 years ago

Released in 6.1.0.

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