Issue 3540: Fix baseUrl slash (#3546)

closes #3540 and #3545 

Tests:
```js
/// <reference types="Cypress" />

it('test url', function () {
    cy.visit('/')
    var baseUrl = Cypress.config('baseUrl')
    //baseUrl = baseUrl + '/'    // bug in Cypress - add slash
    cy.url().should('eq', Cypress.env('test_url'))
    cy.url().should('eq', baseUrl)
})

it('test url - copy paste from @jennifer-shehane', function () {
    cy.visit('/')
    cy.url().should('eq', Cypress.config('baseUrl'))
})
```

![obraz](https://user-images.githubusercontent.com/905878/53121397-10f83780-354c-11e9-8495-2474ced106e6.png)
This commit is contained in:
Adam Stachowicz
2019-02-21 23:50:50 +00:00
committed by Chris Breiding
parent ee74bf5646
commit 48265dd60f
2 changed files with 30 additions and 3 deletions

View File

@@ -230,8 +230,10 @@ module.exports = {
.value()
if url = config.baseUrl
## always strip trailing slashes
config.baseUrl = _.trimEnd(url, "/")
## replace multiple slashes at the end of string to single slash
## so http://localhost/// will be http://localhost/
## https://regexr.com/48rvt
config.baseUrl = url.replace(/\/\/+$/, "/")
_.defaults(config, defaults)

View File

@@ -509,9 +509,34 @@ describe "lib/config", ->
it "namespace=__cypress", ->
@defaults "namespace", "__cypress"
it "baseUrl=http://localhost:8000/app/", ->
@defaults "baseUrl", "http://localhost:8000/app/", {
baseUrl: "http://localhost:8000/app///"
}
it "baseUrl=http://localhost:8000/app/", ->
@defaults "baseUrl", "http://localhost:8000/app/", {
baseUrl: "http://localhost:8000/app//"
}
it "baseUrl=http://localhost:8000/app", ->
@defaults "baseUrl", "http://localhost:8000/app", {
baseUrl: "http://localhost:8000/app//"
baseUrl: "http://localhost:8000/app"
}
it "baseUrl=http://localhost:8000/", ->
@defaults "baseUrl", "http://localhost:8000/", {
baseUrl: "http://localhost:8000//"
}
it "baseUrl=http://localhost:8000/", ->
@defaults "baseUrl", "http://localhost:8000/", {
baseUrl: "http://localhost:8000/"
}
it "baseUrl=http://localhost:8000", ->
@defaults "baseUrl", "http://localhost:8000", {
baseUrl: "http://localhost:8000"
}
it "javascripts=[]", ->