dotnet / dotnet/dotnet-api-docs
Incorrect HTTP redirect for unsupported locales
- Dominant language
- C#
- Stars
- 949
- Forks
- 1.7k
- Avg merge
- 3d 27m
- Merged PRs (30d)
- 49
Description
Hi, I believe I've found a bug in the "missing locale" HTTP redirect logic for learn.microsoft.com.
For context, I'm writing a tool that can automatically open links to Microsoft's documentation. I'd like to open the links in the user's locale. For example, for the documentation page for `Console.Write`:
- English/US locales would open https://learn.microsoft.com/en-us/dotnet/api/System.Console.Write
- German locales would open https://learn.microsoft.com/de-de/dotnet/api/System.Console.Write
This is generally working, but for user locales that don't have a corresponding page on learn.microsoft.com (e.g. en-IT), there is an HTTP 301 redirect to `en-US` that ends up generating an invalid URL:
- For the URL https://learn.microsoft.com/en-it/dotnet/api/System.Console.Write
- An HTTP 301 is generated to redirect to `/en-us/en-IT/dotnet/api/System.Console.Write` (note the double locale in the URL)
- This leads to an HTTP 404.
I would expect the HTTP 301 to be `/en-us/dotnet/api/System.Console.Write` in this case.
Contributor guide
Assessment
This issue has not been assessed yet.