Skip to content

Commit 122081d

Browse files
JulienPalardvstinner
authored andcommitted
bpo-31159: fix language switch regex on unknown yet built languages. (#3039)
This fix a regex issue (a missing non-matching group around an 'or' list) and the specific possible case where a translation is built but not yet in known by the picker, but not explicitly listing possible languages in the regex.
1 parent b811d66 commit 122081d

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

Doc/tools/static/switchers.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@
110110
// Returns the path segment of the language as a string, like 'fr/'
111111
// or '' if not found.
112112
function language_segment_from_url(url) {
113-
var language_regexp = '\.org/(' + Object.keys(all_languages).join('|') + '/)';
113+
var language_regexp = '\.org/([a-z]{2}(?:-[a-z]{2})?/)';
114114
var match = url.match(language_regexp);
115115
if (match !== null)
116116
return match[1];
@@ -120,7 +120,7 @@
120120
// Returns the path segment of the version as a string, like '3.6/'
121121
// or '' if not found.
122122
function version_segment_in_url(url) {
123-
var language_segment = '(?:(?:' + Object.keys(all_languages).join('|') + ')/)';
123+
var language_segment = '(?:[a-z]{2}(?:-[a-z]{2})?/)';
124124
var version_segment = '(?:(?:' + version_regexs.join('|') + ')/)';
125125
var version_regexp = '\\.org/' + language_segment + '?(' + version_segment + ')';
126126
var match = url.match(version_regexp);

0 commit comments

Comments
 (0)