diff --git a/cli/CHANGELOG.md b/cli/CHANGELOG.md index a9f8b9aba885..feabaa545a98 100644 --- a/cli/CHANGELOG.md +++ b/cli/CHANGELOG.md @@ -13,6 +13,7 @@ _Released 11/21/2023 (PENDING)_ - Fixed an issue where dynamic intercept aliases now show with alias name instead of "no alias" in driver. Addresses [#24653](https://github.com/cypress-io/cypress/issues/24653) - Fixed an issue where [aliasing individual requests](https://docs.cypress.io/api/commands/intercept#Aliasing-individual-requests) with `cy.intercept()` led to an error when retrieving all of the aliases with `cy.get(@alias.all)` . Addresses [#25448](https://github.com/cypress-io/cypress/issues/25448) - The URL of the application under test and command error "Learn more" links now open externally instead of in the Cypress-launched browser. Fixes [#24572](https://github.com/cypress-io/cypress/issues/24572). +- Fixed issue where some URLs would timeout in pre-request correlation. Addressed in [#28354](https://github.com/cypress-io/cypress/pull/28354). **Misc:** diff --git a/packages/network/lib/uri.ts b/packages/network/lib/uri.ts index 9e598013c367..12c5943b5d23 100644 --- a/packages/network/lib/uri.ts +++ b/packages/network/lib/uri.ts @@ -87,7 +87,11 @@ export function addDefaultPort (urlToCheck: any) { } export function getPath (urlToCheck: string) { - return url.parse(urlToCheck).path + // since we are only concerned with the pathname and search properties, + // we can set the base to a fake base to handle relative urls + const url = new URL(urlToCheck, 'http://fake-base.com') + + return `${url.pathname}${url.search}` } const localhostIPRegex = /^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/ diff --git a/packages/network/test/unit/uri_spec.ts b/packages/network/test/unit/uri_spec.ts index 3f648f60fc2e..9f433b5ff543 100644 --- a/packages/network/test/unit/uri_spec.ts +++ b/packages/network/test/unit/uri_spec.ts @@ -4,6 +4,24 @@ import { URL } from 'url' import { uri } from '../../lib' describe('lib/uri', () => { + context('.getPath', () => { + it('returns the pathname and search', () => { + expect(uri.getPath('http://localhost:9999/foo/bar?baz=quux#/index.html')).to.eq('/foo/bar?baz=quux') + }) + + it('supports encoded characters', () => { + expect(uri.getPath('http://localhost:9999?foo=0%3C1')).to.eq('/?foo=0%3C1') + }) + + it('does not encode the "|" character', () => { + expect(uri.getPath('http://localhost:9999?foo=bar|baz')).to.eq('/?foo=bar|baz') + }) + + it('works with relative urls', () => { + expect(uri.getPath('/foo/bar?foo=bar|baz')).to.eq('/foo/bar?foo=bar|baz') + }) + }) + context('.isLocalhost', () => { it('http://localhost is localhost', () => { expect(uri.isLocalhost(new URL('http://localhost'))).to.be.true