dotnet / dotnet/dotnet-api-docs

Incorrect HTTP redirect for unsupported locales

Open
#9,000 1 comment 0 reactions 0 assignees View on GitHub
area-Infrastructure broken-link Pri3 untriaged
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

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.