Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions packages/driver/cypress/integration/cypress/location_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -426,5 +426,14 @@ describe('src/cypress/location', () => {

expect(url).to.eq('http://localhost:3500/fixtures/sinon.html')
})

// https://github.com/cypress-io/cypress/issues/5090
it('handles query param with two dots', function () {
let url = this.normalize('?foo=..')

url = Location.qualifyWithBaseUrl('http://localhost:3500/', url)

expect(url).to.eq('http://localhost:3500/?foo=..')
})
})
})
38 changes: 8 additions & 30 deletions packages/driver/src/cypress/location.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,12 @@ class $Location {
}

static isUrlLike (url) {
// https://github.com/cypress-io/cypress/issues/5090
// In the case of a url like /?foo=..
if (/\.{2,}/.test(url)) {
return false
}

// beta.cypress.io
// aws.amazon.com/bucket/foo
// foo.bar.co.uk
Expand All @@ -139,18 +145,7 @@ class $Location {
}

static fullyQualifyUrl (url) {
if (this.isFullyQualifiedUrl(url)) {
return url
}

const existing = new UrlParse(window.location.href)

// always normalize against our existing origin
// as the baseUrl so that we do not accidentally
// have relative url's
url = new UrlParse(url, existing.origin)

return url.toString()
return this.resolve(window.location.origin, url)
}

static mergeUrlWithParams (url, params) {
Expand Down Expand Up @@ -228,24 +223,7 @@ class $Location {
}

static resolve (from, to) {
// if to is fully qualified then
// just return that
if (this.isFullyQualifiedUrl(to)) {
return to
}

// else take from and figure out if
// to is relative or absolute-relative

// if to is absolute relative '/foo'
if (this.isAbsoluteRelative(to)) {
// get origin from 'from'
const { origin } = this.create(from)

return this.join(origin, to)
}

return this.join(from, to)
return new URL(to, from).toString()
}

static create (remote) {
Expand Down