mirror of
https://github.com/cypress-io/cypress.git
synced 2026-02-06 07:10:12 -06:00
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')) }) ``` 
This commit is contained in:
committed by
Chris Breiding
parent
ee74bf5646
commit
48265dd60f
@@ -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)
|
||||
|
||||
|
||||
@@ -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=[]", ->
|
||||
|
||||
Reference in New Issue
Block a user