Skip to content

Commit

Permalink
bpo-31159: fix language switch regex on unknown yet built languages. (#…
Browse files Browse the repository at this point in the history
…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.
  • Loading branch information
JulienPalard authored and vstinner committed Aug 9, 2017
1 parent b811d66 commit 122081d
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Doc/tools/static/switchers.js
Expand Up @@ -110,7 +110,7 @@
// Returns the path segment of the language as a string, like 'fr/' // Returns the path segment of the language as a string, like 'fr/'
// or '' if not found. // or '' if not found.
function language_segment_from_url(url) { function language_segment_from_url(url) {
var language_regexp = '\.org/(' + Object.keys(all_languages).join('|') + '/)'; var language_regexp = '\.org/([a-z]{2}(?:-[a-z]{2})?/)';
var match = url.match(language_regexp); var match = url.match(language_regexp);
if (match !== null) if (match !== null)
return match[1]; return match[1];
Expand All @@ -120,7 +120,7 @@
// Returns the path segment of the version as a string, like '3.6/' // Returns the path segment of the version as a string, like '3.6/'
// or '' if not found. // or '' if not found.
function version_segment_in_url(url) { function version_segment_in_url(url) {
var language_segment = '(?:(?:' + Object.keys(all_languages).join('|') + ')/)'; var language_segment = '(?:[a-z]{2}(?:-[a-z]{2})?/)';
var version_segment = '(?:(?:' + version_regexs.join('|') + ')/)'; var version_segment = '(?:(?:' + version_regexs.join('|') + ')/)';
var version_regexp = '\\.org/' + language_segment + '?(' + version_segment + ')'; var version_regexp = '\\.org/' + language_segment + '?(' + version_segment + ')';
var match = url.match(version_regexp); var match = url.match(version_regexp);
Expand Down

0 comments on commit 122081d

Please sign in to comment.