You've already forked uutils.github.io
mirror of
https://github.com/uutils/uutils.github.io.git
synced 2026-06-10 16:12:28 -07:00
Fix language selector regex to match zh-Hant, zh-Hans, nb-NO, etc.
The URL matching regex only accepted two-letter codes or two-letter plus two uppercase (e.g., pt-BR), missing codes like zh-Hant with longer suffixes. Use [a-zA-Z]+ after the hyphen to match all codes.
This commit is contained in:
@@ -89,8 +89,8 @@ cat >> "$HEAD_HBS" << 'ENDSCRIPT'
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
var path = window.location.pathname;
|
||||
// Match both deployed (/coreutils/docs[-lang]/utils/X.html) and local (book[-lang]/utils/X.html)
|
||||
var match = path.match(/\/(?:coreutils\/)?docs(?:-([a-z]{2}(?:-[A-Z]{2})?))?\/utils\/(\w+)\.html/)
|
||||
|| path.match(/\/book(?:-([a-z]{2}(?:-[A-Z]{2})?))?\/utils\/(\w+)\.html/);
|
||||
var match = path.match(/\/(?:coreutils\/)?docs(?:-([a-zA-Z]{2}(?:-[a-zA-Z]+)?))?\/utils\/(\w+)\.html/)
|
||||
|| path.match(/\/book(?:-([a-zA-Z]{2}(?:-[a-zA-Z]+)?))?\/utils\/(\w+)\.html/);
|
||||
if (!match) return;
|
||||
|
||||
var currentLang = match[1] || 'en';
|
||||
|
||||
Reference in New Issue
Block a user