diff --git a/packages/driver/cypress/integration/commands/net_stubbing_spec.ts b/packages/driver/cypress/integration/commands/net_stubbing_spec.ts index 11751aa3eda7..6630bf43dca9 100644 --- a/packages/driver/cypress/integration/commands/net_stubbing_spec.ts +++ b/packages/driver/cypress/integration/commands/net_stubbing_spec.ts @@ -2477,6 +2477,23 @@ describe('network stubbing', { retries: 2 }, function () { cy.wait('@netAlias').its('response.body').should('equal', 'my value') }) + + // https://github.com/cypress-io/cypress/issues/14444 + it('can use dot in request alias', () => { + cy.intercept('/users', (req) => { + req.alias = 'get.url' + req.reply('foo') + }) + + cy.window().then((win) => { + const xhr = new win.XMLHttpRequest() + + xhr.open('GET', '/users') + xhr.send() + }) + + cy.wait('@get.url') + }) }) }) }) diff --git a/packages/driver/src/cy/commands/waiting.js b/packages/driver/src/cy/commands/waiting.js index c2e905c2ecd7..f8d2b1fd5558 100644 --- a/packages/driver/src/cy/commands/waiting.js +++ b/packages/driver/src/cy/commands/waiting.js @@ -100,11 +100,16 @@ module.exports = (Commands, Cypress, cy, state) => { _.keys(cy.state('aliases')).includes(str.slice(1))) { specifier = null } else { - // potentially request, response or index + // potentially request, response const allParts = _.split(str, '.') + const last = _.last(allParts) - str = _.join(_.dropRight(allParts, 1), '.') - specifier = _.last(allParts) + if (last === 'request' || last === 'response') { + str = _.join(_.dropRight(allParts, 1), '.') + specifier = _.last(allParts) + } else { + specifier = null + } } let aliasObj