mdn / yari

The platform code behind MDN Web Docs
Mozilla Public License 2.0
1.16k stars 486 forks source link

fix(build): prevent adding `only-in-en-us` css class to external links #11327

Open yin1999 opened 2 weeks ago

yin1999 commented 2 weeks ago

Summary

Fixes: mdn/translated-content#20809

Problem

The resolved redirection link may also be an external one. But we haven't check this before assigning the enUSFallbackURL, which caused the only-in-en-us CSS class to be added accidentally to the external links.

Solution

Check whether the resolved URL is an external one, if so, do not assign the enUSFallbackURL. Which means, the only-in-en-us CSS class would not be added.


Screenshots

Checkout the git commit sha f277be087b9484b077fc734e5192d83bc3ee04a1, which is the last commit sha before the fix in translated-content (mdn/translated-content#21711).

Check the section /zh-CN/docs/Mozilla/Add-ons/WebExtensions/Your_first_WebExtension#打包和发布:

Before

See: mdn/translated-content#20809

After

image


How did you test this change?

Run yarn dev, and check the rendered page.