Skip to content

Redirect doesn't work if there's a leading space in the address #4707

Description

@sean-roberts

Describe the bug

if I have a leading space in a redirect, the redirect doesn't work.

This was obviously an issue caused by user error but I unexpectedly lost a lot of time on this cursed space. I believe this would be a quick win to resolve these typos issues by trimming the URI as they are known to not match the URI spec. If there is more nuance here than I am unaware of (most likely), then we should be able to trim reliably if the redirect trimmed redirect starts with ^http[s]?:\/\/

Steps to reproduce

Use a leading space in the to field of a redirect.

[[redirects]]
  from = "/test"
  to = " https://www.netlify.com"
  status = 200

Configuration

see steps to repro

Environment

System:
    OS: macOS 12.4
    CPU: (10) arm64 Apple M1 Pro
    Memory: 3.74 GB / 32.00 GB
    Shell: 5.8.1 - /bin/zsh
  Binaries:
    Node: 16.13.1 - /opt/homebrew/opt/nvm/versions/node/v16.13.1/bin/node
    Yarn: 1.22.17 - /opt/homebrew/opt/nvm/versions/node/v16.13.1/bin/yarn
    npm: 8.1.2 - /opt/homebrew/opt/nvm/versions/node/v16.13.1/bin/npm
  npmGlobalPackages:
    netlify-cli: 10.3.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions