Skip to content

Commit

Permalink
fix(pkg/driver): unicode character escaping in url for .request command
Browse files Browse the repository at this point in the history
Use encodeURI inside `cy.request` to make sure the url does not contain
any unescaped Unicode character.

Fixes cypress-io#5274
  • Loading branch information
avallete committed Nov 27, 2019
1 parent 9280333 commit 4b8e583
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions packages/driver/src/cy/commands/request.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,15 @@ module.exports = (Commands, Cypress, cy, state, config) ->
if originOrBase = config("baseUrl") or cy.getRemoteLocation("origin")
options.url = $Location.qualifyWithBaseUrl(originOrBase, options.url)

## Make sure the url unicode characters are properly escaped
## https://github.com/cypress-io/cypress/issues/5274
try
options.url = decodeURI(options.url)
catch URIError
# The url is not already encoded just silence the error
finally
options.url = encodeURI(options.url)

## if options.url isnt FQDN then we need to throw here
## if we made a request prior to a visit then it needs
## to be filled out
Expand Down

0 comments on commit 4b8e583

Please sign in to comment.