Skip to content

Commit 7088f01

Browse files
committed
Streamline handling of version home page languages
1 parent 4574e50 commit 7088f01

File tree

1 file changed

+5
-13
lines changed

1 file changed

+5
-13
lines changed

src/components/GlossaryInjector.tsx

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -36,19 +36,11 @@ const GlossaryInjector: React.FC<GlossaryInjectorProps> = ({ children }) => {
3636
const path = window.location.pathname;
3737

3838
// Check for various version index patterns
39-
// English versions
40-
if (path.match(/\/docs\/latest\/?$/) ||
41-
path.match(/\/docs\/latest\/index(\.html)?/) ||
42-
path.match(/\/docs\/[0-9]+\.[0-9]+\/?$/) ||
43-
path.match(/\/docs\/[0-9]+\.[0-9]+\/index(\.html)?/)) {
44-
return true;
45-
}
46-
47-
// Japanese versions
48-
if (path.match(/\/ja-jp\/docs\/latest\/?$/) ||
49-
path.match(/\/ja-jp\/docs\/latest\/index(\.html)?/) ||
50-
path.match(/\/ja-jp\/docs\/[0-9]+\.[0-9]+\/?$/) ||
51-
path.match(/\/ja-jp\/docs\/[0-9]+\.[0-9]+\/index(\.html)?/)) {
39+
const localePrefix = '(?:/ja-jp)?'; // Matches either '/ja-jp' or nothing
40+
if (path.match(new RegExp(`${localePrefix}/docs/latest/?$`)) ||
41+
path.match(new RegExp(`${localePrefix}/docs/latest/index(\\.html)?`)) ||
42+
path.match(new RegExp(`${localePrefix}/docs/[0-9]+\\.[0-9]+/?$`)) ||
43+
path.match(new RegExp(`${localePrefix}/docs/[0-9]+\\.[0-9]+/index(\\.html)?`))) {
5244
return true;
5345
}
5446
}

0 commit comments

Comments
 (0)