diff --git a/core/src/main/java/hudson/model/Descriptor.java b/core/src/main/java/hudson/model/Descriptor.java index 817115c3ad17..32b9f1dd0cf0 100644 --- a/core/src/main/java/hudson/model/Descriptor.java +++ b/core/src/main/java/hudson/model/Descriptor.java @@ -1007,6 +1007,10 @@ public static URL getStaticHelpUrl(StaplerRequest req, Klass c, String suffix if (url != null) return url; url = c.getResource(base + '_' + locale.getLanguage() + ".html"); if (url != null) return url; + if (locale.getLanguage().equals("en")) { + url = c.getResource(base + ".html"); + if (url != null) return url; + } } // default diff --git a/core/src/test/java/hudson/GetLocaleStaticHelpUrlTest.java b/core/src/test/java/hudson/GetLocaleStaticHelpUrlTest.java index 5fd822bc1c55..a61fc0d54656 100644 --- a/core/src/test/java/hudson/GetLocaleStaticHelpUrlTest.java +++ b/core/src/test/java/hudson/GetLocaleStaticHelpUrlTest.java @@ -36,6 +36,7 @@ import java.util.Enumeration; import java.util.Locale; import org.junit.jupiter.api.Test; +import org.jvnet.hudson.test.Issue; import org.kohsuke.stapler.StaplerRequest; import org.kohsuke.stapler.lang.Klass; @@ -191,6 +192,24 @@ public void getStaticHelpUrlAcceptZhResMore() { assertThatLocaleResourceIs(id, "help-id_zh_CN.html"); } + @Issue("JENKINS-73246") + @Test + public void getStaticHelpUrlAcceptEnFirst() { + // Accept-Language: en-US,en;q=0.9,de;q=0.8 + StaplerRequest req = mockStaplerRequest( + Locale.US, + Locale.ENGLISH, + Locale.GERMAN + ); + + Klass klass = mockKlass( + "help-id.html", + "help-id_de.html" + ); + URL id = Descriptor.getStaticHelpUrl(req, klass, "-id"); + assertThatLocaleResourceIs(id, "help-id.html"); + } + private StaplerRequest mockStaplerRequest(Locale... localeArr) { StaplerRequest req = mock(StaplerRequest.class); Enumeration locales = Collections.enumeration(Arrays.asList(localeArr));