@sonic-equipment/ui 260.0.1 → 260.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -3,6 +3,7 @@ import { jsx, jsxs } from 'react/jsx-runtime';
3
3
  import { useState, useEffect } from 'react';
4
4
  import { useCookie } from '../cookies/use-cookie.js';
5
5
  import { useCountriesLanguages } from '../country-selector/use-countries-languages.js';
6
+ import { isCountryLanguageCode } from '../intl/types.js';
6
7
  import { useFormattedMessage } from '../intl/use-formatted-message.js';
7
8
  import { useIntl } from '../intl/use-intl.js';
8
9
  import { useNavigate } from '../shared/routing/use-navigate.js';
@@ -70,10 +71,23 @@ function ConnectedCountryLanguageSelector({ className, countries: _countries, is
70
71
  const optionLanguageLabel = `clselector.language.${languageCode}.${languageCode}`;
71
72
  // add option key to group's options
72
73
  options.push(optionKey);
73
- const { alternativeHrefs, basePathname, pathname } = router.url;
74
- const path = alternativeHrefs && alternativeHrefs[optionKey]
75
- ? `/${optionKey}${alternativeHrefs[optionKey]}`
76
- : pathname.replace(`/${basePathname.split('/')[1]}`, `/${optionKey}`);
74
+ const { alternativeHrefs, pathname } = router.url;
75
+ let path;
76
+ if (alternativeHrefs && alternativeHrefs[optionKey]) {
77
+ path = `/${optionKey}${alternativeHrefs[optionKey]}`;
78
+ }
79
+ else if (!alternativeHrefs ||
80
+ Object.keys(alternativeHrefs).length === 0) {
81
+ const currentCountryLanguage = pathname.split('/')[1]?.toLowerCase();
82
+ path = isCountryLanguageCode(currentCountryLanguage)
83
+ ? pathname
84
+ .toLowerCase()
85
+ .replace(`${currentCountryLanguage}`, `${optionKey}`)
86
+ : `/${optionKey}${pathname}`;
87
+ }
88
+ else {
89
+ path = `/${optionKey}`;
90
+ }
77
91
  // add option key/value to menu options
78
92
  menuOptions[optionKey] =
79
93
  environment === 'next-production' ? (jsx("span", { lang: languageCode, children: `${t(optionCountryLabel)} - ${t(optionLanguageLabel)}` })) : (
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sonic-equipment/ui",
3
- "version": "260.0.1",
3
+ "version": "260.0.2",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "engines": {