Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle multiple slashes in url #10989

Open
1 task
DarthTicius opened this issue May 9, 2024 · 4 comments
Open
1 task

Handle multiple slashes in url #10989

DarthTicius opened this issue May 9, 2024 · 4 comments
Assignees
Labels
- P4: important Violate documented behavior or significantly impacts performance (priority)

Comments

@DarthTicius
Copy link

Astro Info

Astro                    v4.1.2
Node                     v20.12.0
System                   macOS (arm64)
Package Manager          npm
Output                   server
Adapter                  @astrojs/cloudflare
Integrations             @astrojs/tailwind
                         @astrojs/preact

If this issue only occurs in one browser, which browser is a problem?

No response

Describe the Bug

We want to redirect user if url contains multiple slashes
https://www.example.com/this//is/my/////directory to https://www.example.com/this/is/my/directory

But on the middleware side we do not get raw url : https://www.example.com/this//is/my/////directory
instead we are getting already sanitized version https://www.example.com/this/is/my/directory.

What's the expected result?

Expecting the url in client to be sanitized and not remaining https://www.example.com/this//is/my/////directory

Link to Minimal Reproducible Example

https://stackblitz.com/edit/github-tdbrwm?file=src%2Fmiddleware.ts

Participation

  • I am willing to submit a pull request for this issue.
@github-actions github-actions bot added the needs triage Issue needs to be triaged label May 9, 2024
@ematipico
Copy link
Member

ematipico commented May 9, 2024

I believe this is a known limitation because we can't translate this//is/my/////directory into the file system.

@cauboy
Copy link

cauboy commented May 9, 2024

Is there no way to get the original request with raw initial URL somewhere in Astro?

Would that mean that the only way to accomplish that is to put a reverse-proxy in front of Astro where the URL gets sanitized?

One reason for sanitizing URLs is for SEO. Google might think of '/path///other' and /path/other' as two separate things potentially leading to duplicate content.

@matthewp
Copy link
Contributor

matthewp commented May 9, 2024

This is SSR so I wouldn't expect it to have that constraint. Did you debug to see where it gets stripped away?

@matthewp
Copy link
Contributor

matthewp commented May 9, 2024

Looks like this was caused by this: #7935

In retrospect I think this PR was a mistake. @DarthTicius would you be interested in submitting a PR to fix?

@matthewp matthewp added - P4: important Violate documented behavior or significantly impacts performance (priority) and removed needs triage Issue needs to be triaged labels May 9, 2024
@matthewp matthewp self-assigned this May 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
- P4: important Violate documented behavior or significantly impacts performance (priority)
Projects
None yet
Development

No branches or pull requests

4 participants